WP 5.3 – Breaking changes

This is pretty big, and I’m guessing that a good number of people that have WP_DEBUG_LOG turned on (like me, sorry Scott) might see it filling up fast when 5.3 lands, and there might be some fatal errors, too.

The discussion is here:

https://core.trac.wordpress.org/ticket/47678

The gist is that they are introducing some modern PHP-isms (where “modern” is 5.6 from 2014) and although they fix some performance issues, they do break compatibility with some code.

The fix is overall pretty trivial, basically any code that is overriding core’s code that is changing will need to update function signatures (and it appears that there were about 50 cases of this).

For instance, the old signature might be:

function walk( $elements, $max_depth )

And the new signature would be:

function walk( $elements, $max_depth, ...$args )

No actual logic needs to be changed, just the function/method signature. This is similar to when PHP enforced the __construct() method in 7.0.

The most problematic change is a fatal error (not a warning) with the Walker class which WordPress uses for a lot of different things.

The recommendation is to grep for something like:

find /var/www/ -type f -name "*.php" | grep -v "/wp-includes/" | xargs grep -PHns "function (?:paged_)?walk\s*\(\s*\\$"

Ignore anything from core and only focus on plugins and themes. There will false-positives (specifically there’s something in ACF that matches this but isn’t affected) but you are generally looking for something that has two parameters, $elements and $max_depth. Then just update with the signature above.

For other warnings no related to the Walker class you might just need to poke around and see what’s changed.