Topic on Extension talk:DynamicPageListEngine

Fix for PHP 8.1 (TypeError)

4
GSSNYC (talkcontribs)

In PHP 8.1, there is a TypeError when calling mw.ext.dpl.getPages on account of lines 91 and 104 in /includes/DpleFeatureNamespace.php - the use of PHP's `count` causes an exception if namespace is not provided (or if notNamespaces is not provided) because it attempts to call count on null. This can easily be fixed with PHP 7.0's null-coalescing operator ('??'), or alternatively to support older versions you can just use a ternary to check if the array is null and replace with an empty array before calling count.

(Another option might be to wrap the switch cases in an if statement.)

I would submit a patch for this myself but unfortunately I do not have experience with MediaWiki's/Gerrit submission process and don't immediately have the time to work out how to do it.

GSSNYC (talkcontribs)

The same applies to /includes/DpleFeatureExtra.php, line 85.

GSSNYC (talkcontribs)

...and /includes/DpleFeatureExtrax.php, line 83.

RV1971 (talkcontribs)

Thanks for spotting this. Fix has been uploaded to Gerrit for review.

Reply to "Fix for PHP 8.1 (TypeError)"