Fixed Unable to perform clean install on CLI with PHP 8.0

Jake B.

Well-known member
Affected version
2.2.3
I haven't tried the web installer, but I assume it's the same

Code:
[www@docker-df876fg028 html]$ php cmd.php xf:install -v
All 4918 checked files are present and correct. :)
Database name: xenforo
Name of the administrator user (default: Admin): Admin


In Username.php line 142:
                                                                  
  [ErrorException]                                                
  [E_WARNING] Attempt to read property "usernameLength" on array  
                                                                  

Exception trace:
  at /usr/share/nginx/html/src/XF/Validator/Username.php:142
 XF::handlePhpError() at /usr/share/nginx/html/src/XF/Validator/Username.php:142
 XF\Validator\Username->setupOptionDefaults() at /usr/share/nginx/html/src/XF/Validator/AbstractValidator.php:19
 XF\Validator\AbstractValidator->__construct() at /usr/share/nginx/html/src/XF/Container.php:270
 XF\Container->createObject() at /usr/share/nginx/html/src/XF/App.php:1704
 XF\App->XF\{closure}() at /usr/share/nginx/html/src/XF/Container.php:228
 XF\Container->create() at /usr/share/nginx/html/src/XF/App.php:3000
 XF\App->validator() at /usr/share/nginx/html/src/XF/Cli/Command/Install.php:163
 XF\Cli\Command\Install->execute() at /usr/share/nginx/html/src/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /usr/share/nginx/html/src/vendor/symfony/console/Application.php:992
 Symfony\Component\Console\Application->doRunCommand() at /usr/share/nginx/html/src/vendor/symfony/console/Application.php:255
 Symfony\Component\Console\Application->doRun() at /usr/share/nginx/html/src/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /usr/share/nginx/html/src/XF/Cli/Runner.php:109
 XF\Cli\Runner->run() at /usr/share/nginx/html/cmd.php:15

xf:install [--user USER] [--password PASSWORD] [--email [EMAIL]] [--title TITLE] [--url URL] [--skip-statistics] [--clear]
 

Chris D

XenForo developer
Staff member
This seems to be a behaviour change in PHP 8.0 and it isn't a new issue in XF 2.2.3 as far as I can tell.

PHP:
$array = [];
$value = $array->someProperty;

In PHP 7.4 this code results in [E_NOTICE] Trying to get property 'someProperty' of non-object .
In PHP 8.0 the code results in [E_WARNING] Attempt to read property "someProperty" on array

We used to get away with this when it was just a notice.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.3 Patch 1).

Change log:
Bypass some username validation for improved PHP 8.0 compat.
There may be a delay before changes are rolled out to the XenForo Community.
 

webbouk

Well-known member
Forgive my ignorance but what is CLI ?

(It's late, I'm tired, been a tough day, and I'll most likely make a fool of myself :D )
 
Top