Not a bug PHP 8 errors and warnings

Karelke

Well-known member
Affected version
2.2.9
On XenForo 2.2.9, the following warnings are present with PHP 8.

Tools used: https://github.com/PHPCompatibility/PHPCompatibility

Code:
FILE: /usr/src/myapp/src/XF/Captcha/HCaptcha.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 1 ERROR AFFECTING 1 LINE

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 23 | ERROR | The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: '0x47fD9C7F7B1db151F1c0c36a938Ab1BDcDa9CBAA'

    |       | (PHPCompatibility.Miscellaneous.ValidIntegers.HexNumericStringFound)

Code:
FILE: /usr/src/myapp/src/XF/Authentication/Core12.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 42 | WARNING | The value of the password hash algorithm constants has changed in PHP 7.4. Pass a PHP native constant to the password_hash() function instead of using the value of the constant. Found:

    |         | $options['algo'] (PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues.NotAlgoConstant)

 86 | WARNING | The value of the password hash algorithm constants has changed in PHP 7.4. Pass a PHP native constant to the password_needs_rehash() function instead of using the value of the constant. Found:

    |         | $options['algo'] (PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues.NotAlgoConstant)

Code:
FILE: /usr/src/myapp/src/XF/Authentication/Core12.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 42 | WARNING | The value of the password hash algorithm constants has changed in PHP 7.4. Pass a PHP native constant to the password_hash() function instead of using the value of the constant. Found:

    |         | $options['algo'] (PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues.NotAlgoConstant)

 86 | WARNING | The value of the password hash algorithm constants has changed in PHP 7.4. Pass a PHP native constant to the password_needs_rehash() function instead of using the value of the constant. Found:

    |         | $options['algo'] (PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues.NotAlgoConstant)

Code:
FILE: /usr/src/myapp/src/XF/Util/Random.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 3 ERRORS AFFECTING 1 LINE

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 112 | ERROR | Extension 'mcrypt' is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead

     |       | (PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved)

 112 | ERROR | Function mcrypt_create_iv() is deprecated since PHP 7.1 and removed since PHP 7.2; Use random_bytes() or OpenSSL instead

     |       | (PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved)

 112 | ERROR | The constant "MCRYPT_DEV_URANDOM" is deprecated since PHP 7.1 and removed since PHP 7.2 (PHPCompatibility.Constants.RemovedConstants.mcrypt_dev_urandomDeprecatedRemoved)

Code:
FILE: /usr/src/myapp/src/XF/Util/Arr.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 202 | WARNING | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "$args"

     |         | was used, and possibly changed (by reference), on line 195. (PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection)

Code:
FILE: /usr/src/myapp/src/XF/App.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 1 ERROR AFFECTING 1 LINE

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 3088 | ERROR | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "$class"

      |       | was changed on line 3082. (PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.Changed)

Code:
FILE: /usr/src/myapp/src/XF/Template/Compiler/Lexer.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 714 | WARNING | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter

     |         | "$tokens" was used, and possibly changed (by reference), on line 712. (PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection)

Code:
FILE: /usr/src/myapp/src/XF/Mvc/Entity/Finder.php

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  141 | ERROR   | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter

      |         | "$condition" was changed on line 137. (PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.Changed)

 1448 | WARNING | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter

      |         | "$column" was used, and possibly changed (by reference), on line 1442. (PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection)
 
I used xenforo2.2.9. I used it with PHP 8. It didn't give me any errors. Is it an addon related problem? Or is it a problem with your server?

I am currently using xenforo2.2.10 patch.
 
I used xenforo2.2.9. I used it with PHP 8. It didn't give me any errors. Is it an addon related problem? Or is it a problem with your server?

I am currently using xenforo2.2.10 patch.
Same here. No PHP 8 warnings or errors.

I'm using PHP 8.0.22. You might want to check to see what version you have installed and check the other PHP settings.
 
I went through the first handful of warnings you posted, and they were all false positives. Tools like that often require a great deal of manual tuning and filtering.
 
This is the output of some sort of linter rather an operational errors, so I don't think they're a great concern. Things like the mcrypt depreciation notices are there because it's being run for PHP 8.0 which doesn't have these functions, but XF support PHP 7.0 and has checks for if the function exists before it's used. A linter won't know the application-specific nuances of a codebase.
 
If you are using mysql might you be getting an error about it? Mysql 8 I think there is a bug in the last version. I'm using mariadb mariadb 10.3 no errors, everything is fine... As far as I've heard, those who updated to the latest version of mysql got errors.
 
@Baby Community, the output in the first post isn't actually a list of errors. @Karelke is using a static analysis tool to search for potential PHP 8 compatibility issues in the XenForo codebase. The bug you're likely thinking of in MySQL 8.0.29 wouldn't result in errors like this--your MySQL server wouldn't be able to start, so you'd get an error indicating XenForo can't communicate with the database.

I've now gone through all of the issues and found them all to be false positives. You can safely ignore all of those, @Karelke.
 
It's good to have confirmed that XenForo fully supports PHP 8 :)

It was already confirmed, by XF.
PHP 7.0 or newer (PHP 8.0 recommended)

 
Top Bottom