Page MenuHomePhorge

Fix most PHP 8.1 issues

Authored by MacFan4000 on Dec 7 2021, 14:16.
Referenced Files
Unknown Object (File)
Sun, Feb 5, 01:38
Unknown Object (File)
Thu, Feb 2, 18:19
Unknown Object (File)
Fri, Jan 27, 15:51
Unknown Object (File)
Fri, Jan 27, 05:06
Unknown Object (File)
Thu, Jan 26, 07:39
Unknown Object (File)
Thu, Jan 26, 04:50
Unknown Object (File)
Thu, Jan 19, 23:56
Unknown Object (File)
Tue, Jan 17, 08:57



This fixes most issues with PHP 8.1. Some issues still remain that I was unable to fix.

Test Plan

Used PHP linting, tested in browser, checked logs, etc

Diff Detail

rP Phorge
Lint Skipped
Tests Skipped

Event Timeline

I've been think about what to do with this for a while, and I have to say, it's a hard one.

First, thanks for doing this, this is definitively needed. But in its current form, it is effectively impossible to review. There are changes to js files, which I think is a clear indication that this is likely automated.

This patch suppresses the deprecation errors at each site, but there might be a simpler workaround in the same spirit: change the error_reporting calls (of which there are only a handful) to exclude E_DEPRECATED. That would risk masking any other deprecations (probably fine in production, but not in development), whereas this patch risks hiding any non-deprecation errors at these locations.

Depending on how the allow_null RFC is handled, Phabricator/Phorge could potentially need no code changes, except to make it refuse to run on PHP 8.1.

Yeah if that RFC passes then that would make things way easier. And yes I used sed for a lot of the changes.

I got differential working under PHP 8.1 by doing a global replace of single parameter strlen commands to add the null coalesce operator

perl -pi -e 's/(strlen\(\$[a-zA-Z\d_]+)\)/$1 ?? "")/g' `find . -type f -name '*.php'`

There were a couple of other fixes needed to a few isolated preg_match(), trim(), strcasecmp() statements.

Then had to revert the PHP upgrade as PHP 8.1 broke a different application :-/

Ekubischta added a subscriber: Ekubischta.

This revision is nearly impossible to test

See my comments here D25030#1893

Error suppression with "@" is a poor solution to this issue

This revision now requires changes to proceed.Nov 11 2022, 16:11