Jump to content

Topic on Extension talk:Widgets

Is this extension compatible with PHP 8.2?

5
Peculiar Investor (talkcontribs)

I am running MediaWiki 1.39.5 and recently switched to PHP 8.2.x (8.2.12 currently).

We have a Widget test page that loads sample Google presentation, Google document and Google Spreadsheet widgets.

All appear okay. However in the error_log we get:

[07-Nov-2023 23:12:33 UTC] PHP Warning: Undefined array key "width" in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 24 [07-Nov-2023 23:12:33 UTC] PHP Warning: Attempt to read property "value" on null in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 24 [07-Nov-2023 23:12:33 UTC] PHP Warning: Undefined array key "height" in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 25 [07-Nov-2023 23:12:33 UTC] PHP Warning: Attempt to read property "value" on null in w/extensions/Widgets/compiled_templates/ba811dbfd89414d874993a209b5e2eb71ad14d2d_0.wiki.GooglePresentation.php on line 25

I have gone through the individual Widget pages and purged the page so that the compiled templates are refreshed.

These seem to be indicative of something not compatible with PHP 8.2 changes or is some step required to recompile the template(s)?

Kghbln (talkcontribs)

I doubt it. Anyhow, MediaWiki is not compatible with PHP 8.2 either. Did the widget work with earlier versions of PHP, MediaWiki, and Widgets?

Peculiar Investor (talkcontribs)

According to Compatibility#PHP MediaWiki support for PHP 8.0 and above started with 1.39.0. The recent 1.39.5 release announcement makes mention that "Various patches aimed at PHP 8.0, 8.1, and 8.2 support have been back-ported."

The Widget's work as far as the end-user knows. The PHP Warnings in the error_log are something I would expect the Extension:Widgets developers to address.

Cavila (talkcontribs)

I don't know what your widget looks like and how it is used, so this is a wild guess, but the error messages read like the values for those parameters have not been specified. If those values were omitted, did you at least provide defaults or provided an 'if' condition to prevent such errors from occurring?

Cavila (talkcontribs)

Returning to this... I had the same issue, recently. At some point, the Widget extension has become less forgiving when you do not set a value for a parameter defined in the widget, which will trigger the warning you encountered. Like I mentioned at the time, you can use an 'if' condition to get around this[1], but what I didn't know is that defaults (https://www.smarty.net/docs/en/language.modifier.default.tpl) no longer seem to work and will emit same error message. I used the REL1.39 branch of the extension, which installed version 1.4.2, and I am using PHP 8.0.

This no longer works:

<!--{$myparam|escape:'quotes'|default:'Nothing to see here'}

It looks like the issue began with the inclusion of modifier.allowedvalues.php, which does not check for defaults.

[1] For anyone looking for am example, this solution checks if the param is set at all and if it is, if the value is not 'empty', similar to how you would wiki templates

<!--{if ( isset($myparam) && $myparam!="" )}-->
<!--{$myparam|escape:'quotes'}-->
<!--{else}-->
Nothing to see here [optional default]
<!--{/if}-->
Reply to "Is this extension compatible with PHP 8.2?"