Skip to content

Incompatibility with widgets in PHP 8

When upgrading one of my (many) sites, the site crashed with an error about too few arguments being passed into a constructor for Widgets.

I then found this Stack Exchange post which contained the fix:

In case you couldn’t revert to PHP older than 8.1 or fix the widget registration (and you trust your 10+ years old theme), you can update the line 61 of wp-includes/class-wp-widget-factory.php this way :

$this->widgets[ $widget ] = new $widget( $widget, $widget );

So, I logged into my server and fixed the offending code with the fix.

Published inweb hosting