Project

General

Profile

Actions

Bug #21795

closed

PHP 8 compat, continued

Added by Boone Gorges 23 days ago. Updated 13 days ago.

Status:
Resolved
Priority name:
Normal
Assignee:
-
Category name:
-
Target version:
Start date:
2025-01-17
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

PHP 8 compatibility issues are starting to crop up now that we are running in Reclaim. I will use this ticket to track some of them.


Related issues

Related to CUNY Academic Commons - Bug #21799: ACERT site - posts displaying correctly but edit not working after migrationResolvedBoone Gorges2025-01-18

Actions
Actions #1

Updated by Boone Gorges 23 days ago

wordpress-custom-sidebar called some non-static methods statically. Fixed in https://github.com/cuny-academic-commons/cac/commit/89594fc5443862adb7d43de2123529ba6d67c5ac

Actions #3

Updated by Boone Gorges 23 days ago

Actions #4

Updated by Boone Gorges 23 days ago

A bunch of sites were being fatalled by a widget-related bug:

Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /var/www/webroot/ROOT/wp-includes/widgets.php:617 Stack trace: #0 /var/www/webroot/ROOT/wp-includes/widgets.php(617): array_merge() #1 /var/www/webroot/ROOT/wp-includes/class-wp-widget.php(580): _register_widget_update_callback() #2 /var/www/webroot/ROOT/wp-includes/class-wp-widget.php(275): WP_Widget->_register_one() #3 /var/www/webroot/ROOT/wp-includes/class-wp-widget-factory.php(103): WP_Widget->_register() #4 /var/www/webroot/ROOT/wp-includes/class-wp-hook.php(324): WP_Widget_Factory->_register_widgets() #5 /var/www/webroot/ROOT/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #6 /var/www/webroot/ROOT/wp-includes/plugin.php(517): WP_Hook->do_action() #7 /var/www/webroot/ROOT/wp-includes/widgets.php(1870): do_action() #8 /var/www/webroot/ROOT/wp-includes/class-wp-hook.php(324): wp_widgets_init() #9 /var/www/webroot/ROOT/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #10 /var/www/webroot/ROOT/wp-includes/plugin.php(517): WP_Hook->do_action() #11 /var/www/webroot/ROOT/wp-settings.php(700): do_action() #12 /var/www/webroot/ROOT/wp-config.php(327): require_once('...') #13 /var/www/webroot/ROOT/wp-load.php(50): require_once('...') #14 /var/www/webroot/ROOT/wp-blog-header.php(13): require_once('...') #15 /var/www/webroot/ROOT/index.php(17): require('...') #16 {main} thrown in /var/www/webroot/ROOT/wp-includes/widgets.php on line 617

I put a hotfix in core that ensures that the $options variable passed to array_merge() in _register_widget_update_callback() is actually an array. But this is covering up the deeper bug. I can't work on this any more tonight, I'm just putting it here for my notes and in case Jeremy or Ray has a clue what might be happening.

Actions #5

Updated by Raymond Hoh 22 days ago

The projects-by-woothemes plugin is throwing a fatal error:

Uncaught ValueError: Unknown format specifier "a" in /wp-content/plugins/projects-by-woothemes/projects.php:154

This should fix an issue with acert.hunter.cuny.edu. I've addressed this in 2.5.x branch: https://github.com/cuny-academic-commons/cac/commit/fe806c9af3cdce85360027d1d4af6d58edf02726 , but I cannot perform any git operations like pull or push on the Reclaim servers. It's asking for Enter passphrase for key '/home/jelastic/.ssh/id_ed25519', which I do not have access to. Boone, can you pull or cherry-pick the commit when you have the chance?

Actions #6

Updated by Boone Gorges 22 days ago

These changes have been pulled. I'll try to sort out the SSH key issues so that others can pull to the server.

Actions #7

Updated by Boone Gorges 22 days ago

  • Related to Bug #21799: ACERT site - posts displaying correctly but edit not working after migration added
Actions #8

Updated by Boone Gorges 20 days ago

I figured out the widget issue, which was being caused by a plugin called wp-ui that was registering its widget incorrectly. https://github.com/cuny-academic-commons/cac/commit/b66d35b582c23bccad33985a24215706e76feb53

After launch on Reclaim, the error log was filled with notices and fatal errors. I've spent the last few days trying to clear them out. There's too many here to catalog individually (see log at https://github.com/cuny-academic-commons/cac/commits/2.5.x/?since=2025-01-17&until=2025-01-19 for many of them), but they fall into a couple types of main categories:

1. PHP4 constructors in WP_Widget. The recommendations for WP_Widget have changed several times through the last 15 years, and many plugins on the Commons were still using the old PHP4 style constructors, both for the extending widget and also when calling the parent constructor. Because PHP 8 doesn't even read these constructors, the widgets were all being created incorrectly, throwing fatal errors. I don't have a straightforward way of grepping the codebase for this, so I found them mainly by tailing the error log. Whenever I found one, I updated it to use __construct() as necessary.
2. References to undefined constants. Previously, PHP would throw a notice. Now it fatals. I've fixed these manually as I've found them.
3. Type errors. There's a number of changes in PHP8 such that type errors are fatal where they used to be warnings. For example, you can't use array syntax $foo[3] to get the number 4 from an int 12345. Again, I found these and fixed as I came across them.

I also fixed a ton of minor notices (not fatals) in abandoned plugins. Not so much because they're important, but because they were blowing up the PHP error log and making it less useful.

Let's continue to correct items in the upcoming days and weeks.

Actions #9

Updated by Boone Gorges 13 days ago

  • Status changed from New to Resolved

I've done several more rounds of fixing on this, and I think we are pretty well finished for now. There's a handful of notices being thrown in some cases, and occasional fatals that have less to do with PHP 8 than with goofy plugins/themes. I'm going to close out this general ticket.

Actions

Also available in: Atom PDF