Skip to content

Commit

Permalink
[php8.2][compatability] Changes to support php 8.2
Browse files Browse the repository at this point in the history
- Remove depricated utf8_decode function call
- Explicit cast to int for result of division
- returned result from differential.query appears to have changed to
array's and not keyed objects. Patch needs to search the array
  • Loading branch information
Daniel Kozlowski committed Feb 3, 2023
1 parent fbe0274 commit af49388
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/differential/ArcanistDifferentialDependencyGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ private function getCommitHashFromDict($dict) {
$key = null;
}

foreach ($hashes as $hash) {
if ($hash[0] == $key) {
return $hash[1];
}
}
return idx($hashes, $key);
}

Expand Down
3 changes: 2 additions & 1 deletion src/land/engine/ArcanistPhlqLandEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ function execute() {
$timestamp_diff = $commit_unix_date - $diff_date_modified;
# allow for small theshold before tripping the warning
if ($timestamp_diff > 5) {
$pretty_diff = sprintf('%02dh %02dm %02ds', ($timestamp_diff/3600),($timestamp_diff/60%60), $timestamp_diff%60);
$pretty_diff = sprintf('%02dh %02dm %02ds',$timestamp_diff/3600,(int)($timestamp_diff/60) % 60, $timestamp_diff%60.0);

echo tsprintf(
"\n%!\n%W\n",
pht('POTENTIAL UNPUSHED LOCAL CHANGES FOR D%s', $revision_id),
Expand Down
8 changes: 5 additions & 3 deletions src/utils/utf8.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ function phutil_is_utf8_slowly($string, $only_bmp = false) {
* @return int The character length of the string.
*/
function phutil_utf8_strlen($string) {
if (function_exists('utf8_decode')) {
return strlen(utf8_decode($string));
}
//utf8_decode is depricated as of php 8.2
//https://www.php.net/releases/8.2/en.php#deprecations_and_bc_breaks
//if (function_exists('utf8_decode')) {
// return strlen(utf8_decode($string));
//}
return count(phutil_utf8v($string));
}

Expand Down

0 comments on commit af49388

Please sign in to comment.