-
Notifications
You must be signed in to change notification settings - Fork 133
Add support for PHP 8.5 #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a5640a1
5a7a4b6
2cb3fe6
945fd3f
7b86161
b982a26
a373055
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -504,7 +504,7 @@ function convert_phonenumber($param) | |
| $this->load->model('Kalkun_model'); | ||
| $country_code = $this->Kalkun_model->get_setting($param['id_user'])->row('country_code'); | ||
| $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); | ||
| $dial_code = '+'.$phoneNumberUtil->getCountryCodeForRegion($country_code); | ||
| $dial_code = '+'.$phoneNumberUtil->getCountryCodeForRegion(strval($country_code)); | ||
| $number_local = str_replace($dial_code, '0', $param['number']); | ||
| $number_inter = $dial_code.substr($param['number'], 1); | ||
| return array($param['number'], $number_local, $number_inter); | ||
|
Comment on lines
+507
to
510
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainGood cast; add normalization and guard for invalid/empty region (prevents '+0'). Casting to string is correct for PHP 8.x. Add uppercasing and handle empty/unknown region to avoid producing '+0' and bad local/international variants. Apply minimally defensive changes: - $dial_code = '+'.$phoneNumberUtil->getCountryCodeForRegion(strval($country_code));
+ $region = strtoupper((string) $country_code);
+ $cc = $phoneNumberUtil->getCountryCodeForRegion($region);
+ if ($cc === 0) {
+ log_message('warning', 'Unknown/empty country_code for user '.$param['id_user'].' in convert_phonenumber()');
+ // keep current behavior but avoid '+0'
+ return array($param['number'], $param['number'], $param['number']);
+ }
+ $dial_code = '+'.$cc;Verify what is stored in settings to ensure we're passing an ISO 3166-1 alpha-2 region (e.g., 'ID'), not a calling code (e.g., '62'): 🏁 Script executed: #!/bin/bash
# Inspect usages and likely values of `country_code` across the repo
rg -n -C3 '\bcountry_code\b' --hidden -g '!vendor/**'
rg -n -C3 'get_setting\s*\(.*\)\s*->row\(\s*([\'"])country_code\1\)' --hidden -g '!vendor/**'
# Check if code elsewhere treats it as a region vs calling code
rg -n -C3 'getCountryCodeForRegion\(' --hidden -g '!vendor/**'Length of output: 22867 Add uppercasing and guard against invalid regions to prevent '+0' dial codes. The cast to string is correct for PHP 8.x. However, region codes must be uppercase, and getCountryCodeForRegion() returns 0 for invalid regions, which would produce a "+0" dial code. Add normalization and validation: - $dial_code = '+'.$phoneNumberUtil->getCountryCodeForRegion(strval($country_code));
+ $region = strtoupper((string) $country_code);
+ $cc = $phoneNumberUtil->getCountryCodeForRegion($region);
+ if ($cc === 0) {
+ log_message('warning', 'Unknown/empty country_code for user '.$param['id_user'].' in convert_phonenumber()');
+ // keep current behavior but avoid '+0'
+ return array($param['number'], $param['number'], $param['number']);
+ }
+ $dial_code = '+'.$cc;🤖 Prompt for AI Agents |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,7 +243,10 @@ function sendTMobileCZ($uid, $pwd, $phone, $msg, $isFlash = FALSE, $dRpt = FALSE | |
| }; | ||
| log_message('debug', 'TMCZ> SMS sent successfully.'); | ||
|
|
||
| curl_close($curl); | ||
| if ( ! is_php('8.0')) | ||
| { | ||
| curl_close ($curl); | ||
| } | ||
|
Comment on lines
+246
to
+249
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the necessity of skipping curl_close() on PHP 8.0+. While the change follows the pattern established in Please search for documentation to confirm whether there are any issues with calling Additionally, note that 🌐 Web query: 💡 Result: Short answer: No serious issues in PHP 8.0–8.4, but it became a no‑op; starting with PHP 8.5 it is deprecated and will raise deprecation warnings. Details:
If you need compatibility: either unset the handle (unset($ch)) or stop calling curl_close() on PHP 8.5+ (guard the call by PHP version or by checking the handle type). [2][3] Sources: Update curl_close() guard to only skip on PHP 8.5+, not PHP 8.0+. The current implementation is overly conservative. In PHP 8.0–8.4, if ( ! is_php('8.5'))
{
curl_close($curl);
}Or alternatively, remove the guard entirely for PHP 8.0–8.4 compatibility and add it only when PHP 8.5+ support becomes critical. Additionally, 🤖 Prompt for AI Agents |
||
| //$result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => $res); | ||
| return $result; | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| RuntimeException: Non-canonical cast (double) is deprecated, use the (float) cast instead on line 7281 in file /home/runner/work/Kalkun/Kalkun/vendor/econea/nusoap/src/nusoap.php | ||
| RuntimeException: Non-canonical cast (boolean) is deprecated, use the (bool) cast instead on line 7287 in file /home/runner/work/Kalkun/Kalkun/vendor/econea/nusoap/src/nusoap.php | ||
| RuntimeException: Function xml_parser_free() is deprecated since 8.5, as it has no effect since PHP 8.0 on line 6916 in file /home/runner/work/Kalkun/Kalkun/vendor/econea/nusoap/src/nusoap.php | ||
|
|
||
| --- a/src/nusoap.php | ||
| +++ b/src/nusoap.php | ||
| @@ -1263,7 +1263,7 @@ | ||
| $this->setError($errstr); | ||
| } | ||
|
|
||
| - xml_parser_free($this->parser); | ||
| + (PHP_VERSION_ID < 80000) && xml_parser_free($this->parser); | ||
| unset($this->parser); | ||
| } else { | ||
| $this->debug('no xml passed to parseString()!!'); | ||
| @@ -5010,12 +5010,12 @@ | ||
| $this->debug($errstr); | ||
| $this->debug("XML payload:\n" . $wsdl_string); | ||
| $this->setError($errstr); | ||
| - xml_parser_free($this->parser); | ||
| + (PHP_VERSION_ID < 80000) && xml_parser_free($this->parser); | ||
| unset($this->parser); | ||
| return false; | ||
| } | ||
| // free the parser | ||
| - xml_parser_free($this->parser); | ||
| + (PHP_VERSION_ID < 80000) && xml_parser_free($this->parser); | ||
| unset($this->parser); | ||
| $this->debug('Parsing WSDL done'); | ||
| // catch wsdl parse errors | ||
| @@ -6913,7 +6913,7 @@ | ||
| } | ||
| } | ||
| } | ||
| - xml_parser_free($this->parser); | ||
| + (PHP_VERSION_ID < 80000) && xml_parser_free($this->parser); | ||
| unset($this->parser); | ||
| } else { | ||
| $this->debug('xml was empty, didn\'t parse!'); | ||
| @@ -7278,13 +7278,13 @@ | ||
| return (int) $value; | ||
| } | ||
| if ($type == 'float' || $type == 'double' || $type == 'decimal') { | ||
| - return (double) $value; | ||
| + return (float) $value; | ||
| } | ||
| if ($type == 'boolean') { | ||
| if (strtolower($value) == 'false' || strtolower($value) == 'f') { | ||
| return false; | ||
| } | ||
| - return (boolean) $value; | ||
| + return (bool) $value; | ||
| } | ||
| if ($type == 'base64' || $type == 'base64Binary') { | ||
| $this->debug('Decode base64 value'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| RuntimeException: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect on line 39 in file /home/runner/work/Kalkun/Kalkun/vendor/kenjis/ci-phpunit-test/application/tests/_ci_phpunit_test/CIPHPUnitTestReflection.php | ||
|
|
||
| --- a/application/tests/_ci_phpunit_test/CIPHPUnitTestReflection.php | ||
| +++ b/application/tests/_ci_phpunit_test/CIPHPUnitTestReflection.php | ||
| @@ -18,7 +18,9 @@ | ||
| public static function getPrivateMethodInvoker($obj, $method) | ||
| { | ||
| $ref_method = new ReflectionMethod($obj, $method); | ||
| - $ref_method->setAccessible(true); | ||
| + if ( ! is_php('8.1')) { | ||
| + $ref_method->setAccessible(true); | ||
| + } | ||
| $obj = (gettype($obj) === 'object') ? $obj : null; | ||
|
|
||
| return function () use ($obj, $ref_method) { | ||
| @@ -36,7 +38,9 @@ | ||
| } | ||
|
|
||
| $ref_property = $ref_class->getProperty($property); | ||
| - $ref_property->setAccessible(true); | ||
| + if ( ! is_php('8.1')) { | ||
| + $ref_property->setAccessible(true); | ||
| + } | ||
|
|
||
| return $ref_property; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: curl_getinfo called after curl_close on PHP < 8.0.
Line 39 calls
curl_getinfo($request, CURLINFO_HTTP_CODE)after the conditionalcurl_close()at line 36. On PHP versions prior to 8.0, the handle is closed beforecurl_getinfo()is invoked, which will cause the function to fail or return invalid data.Apply this diff to fix the order:
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one @tenzap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I'm a bit dubious. This was already like that before and this pr for php 8.5 doesn't add a regression here. Is this really required? Btw is DND in India still working today as 15 years ago? It is likely I added that regression at sometime because DND doesn't work anymore iirc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point :)
Yes DND has evolved, and there is much larger registry for DND. These would need to be updated for such use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this for now and make the change suggested here appart later (through a pr to check in ci, and then merge if it passes).