Jump to content

Fatal errors upgrading to PHP 8.0


Recommended Posts

Since it looked like others have successfully upgraded to PHP 8, I decided to give it a try. I use Laragon on the dev machine so started with that. Succesfully added PHP 8.0 and got Apache running OK. Tried two sites which noth returned similar fatal error messages:

Site 1

Fatal error: Uncaught Error: Undefined constant "ProcessWire\HTTP_HOST" in M:\laragon\www\processwire\site-ncog\config.php:191 Stack trace: #0 M:\laragon\www\processwire\wire\core\ProcessWire.php(1246): require() #1 M:\laragon\www\processwire\index.php(33): ProcessWire\ProcessWire::buildConfig('M:/laragon/www/...') #2 {main} thrown in M:\laragon\www\processwire\site-ncog\config.php on line 191

Site 2

Breaking news… Fatal Error: Uncaught Error: Undefined constant PDO::MYSQL_ATTR_INIT_COMMAND in M:\laragon\www\BawdHall\wire\core\WireDatabasePDO.php:240

#0 M:\laragon\www\BawdHall\wire\core\ProcessWire.php(514): WireDatabasePDO::getInstance(Object(Config))
#1 M:\laragon\www\BawdHall\wire\core\ProcessWire.php(313): ProcessWire->load(Object(Config))
#2 M:\laragon\www\BawdHall\index.php(52): ProcessWire->__construct(Object(Config))
#3 {main}
thrown (line 240 of M:\laragon\www\BawdHall\wire\core\WireDatabasePDO.php)

Reverted to PHP 7.2 and all is fine. Both sites are on PW 3.0.184 and are in (separate) multi-site installations. Any suggestions? Thanks.

Link to comment
Share on other sites

In site 1, I'd guess that there's a spot where you're missing quotes in $_SERVER['HTTP_HOST'] (i.e., $_SERVER[HTTP_HOST], which will with strict mode turned off interpret HTTP_HOST as the name of a constant in the current namespace).

The error in site 2 points to a missing pdo_mysql extension, so make sure that it's activated and enabled in php.ini.

  • Like 4
Link to comment
Share on other sites

Thanks muchly @BitPoet!

The first was rather obvious - should have spotted that!

The second was more subtle. Inspecting the php.ini from the laragon panel, it looked ok. Opened it directly in an editor and the extensions clearly weren't enabled. Odd, but all working now, thanks.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...