Page MenuHomePhabricator

mediawiki-extensions-widgets: PHP Warning: call_user_func() expects parameter 1 / class 'WidgetRenderer' does not have a method 'initRandomString'
Closed, InvalidPublicBUG REPORT

Description

Steps to replicate the issue:

Use MediaWiki-extensions-Widgets.

/var/www/w/maintenance/showJobs.php

PHP Warning: call_user_func() expects parameter 1 to be a valid callback, class 'WidgetRenderer' does not have a method 'initRandomString' in /var/www/w/includes/Setup.php on line 532

/var/www/w/maintenance/version.php

PHP Warning: call_user_func() expects parameter 1 to be a valid callback, class 'WidgetRenderer' does not have a method 'initRandomString' in /var/www/w/includes/Setup.php on line 532

Same for any other maintenance script.

What happens?:

It shows a PHP warning.

What should have happened instead?:

It shouldn't show a PHP warning.

Software version:

Use MediaWiki 1.39.0.

Why do I think it's caused by Widgets extension? WidgetRenderer can be found in file /w/extensions/Widgets/WidgetRenderer.php.

Event Timeline

Change 871225 had a related patch set uploaded (by Zoranzoki21; author: Zoranzoki21):

[mediawiki/extensions/Widgets@master] Fix PHP warning about initRandomString method

https://gerrit.wikimedia.org/r/871225

Sorry for the delay in responding. And @Kizule - thank you for the fix. But what is the code that is trying to call WidgetRenderer::initRandomString() in the first place?

Sorry for the delay in responding. And @Kizule - thank you for the fix. But what is the code that is trying to call WidgetRenderer::initRandomString() in the first place?

No problem. I found that code here.

It is probably for storing widgets under the compiled_templates directory and making name include random string.

@Kizule - I don't think that link answers the question; that's just a random diff of the code from (I think) 2015, if I'm not mistaken.

I think I may understand the issue. The Widgets extension contained the initRandomString() code (basically, the code you're trying to restore) until November 2022:

https://phabricator.wikimedia.org/rEWIDf86713e332d0433119d4dda21fd7d20df4d48088

About a month later, @adrelanos tried running some (I'm guessing) old jobs, maybe soon after upgrading Widgets to the latest code. These jobs expected initRandomString() to be there, since it existed when they were created, but by the time they were run it was no longer there. Assuming that's the case, this is just a temporary problem that doesn't need fixing.

Change 871225 abandoned by Zoranzoki21:

[mediawiki/extensions/Widgets@master] Fix PHP warning about initRandomString method

Reason:

Per comments in task.

https://gerrit.wikimedia.org/r/871225

PHP Warning: call_user_func() expects parameter 1 to be a valid callback, class 'WidgetRenderer' does not have a method 'initRandomString' in /var/www/w/includes/Setup.php on line 532

Was fixed by @Bawolff here:
https://github.com/wikimedia/mediawiki-extensions-Widgets/commit/f86713e332d0433119d4dda21fd7d20df4d48088#diff-6a6295f752062fb0eec4a9df4e87c164b8d8d3b48023a54a1e682671296eb8a3

Because a legacy leftover:

	"ExtensionFunctions": [
		"WidgetRenderer::initRandomString"
	],

has been removed from extension.json.

This didn't make it's way into the REL1_39 branch that I am using. By cherry-picking the updated extension.json from the master branch, I was able to resolve this issue.

Thank you!

PHP Warning: call_user_func() expects parameter 1 to be a valid callback, class 'WidgetRenderer' does not have a method 'initRandomString' in /var/www/w/includes/Setup.php on line 532

Was fixed by @Bawolff here:
https://github.com/wikimedia/mediawiki-extensions-Widgets/commit/f86713e332d0433119d4dda21fd7d20df4d48088#diff-6a6295f752062fb0eec4a9df4e87c164b8d8d3b48023a54a1e682671296eb8a3

Because a legacy leftover:

	"ExtensionFunctions": [
		"WidgetRenderer::initRandomString"
	],

has been removed from extension.json.

This didn't make it's way into the REL1_39 branch that I am using. By cherry-picking the updated extension.json from the master branch, I was able to resolve this issue.

Thank you!

The extension.json changed should have been backported to the 1.39 branch in d9b86a4010df1844cc9859750fedd729e1d427c8