Page MenuHomePhabricator

Broken interaction of Autoedit API with Extension:FlaggedRevs
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Install both the mentioned below versions of MediaWiki, FlaggedRevs and PageForms
  • Create a form that saves a page
  • Save a page through the form
  • Hook in FlaggedRevs gets hit from [0]
  • TypeError happens in FlaggedRevs

What happens?:

I get a type error in the FlaggedRevs FlaggablePageView class where it assumes the $sectionanchor is always a string, not null. The same thing applies to $extraQuery too.

What should have happened instead?:

The page should save without a TypeError

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

MediaWiki 1.43 (installed from official tarball)
PageForms: 5.8.1 (0b984cc)
FlaggedRevs: REL1_43 (e5c78a2)

Other information (browser name/version, screenshots, etc.):

Stacktrace:

2025-09-01 18:54:55 [bbd282aab71d9c0b99e1fe3b] /Special:FormEdit/ExternalMediaLinks
TypeError: FlaggablePageView::injectPostEditURLParams(): Argument #1 ($sectionAnchor) must be of type string, null given, called in /extensions/FlaggedRevs/includes/frontend/FlaggedRevsUIHooks.php on line 840
#0 /extensions/FlaggedRevs/includes/frontend/FlaggedRevsUIHooks.php(840): FlaggablePageView->injectPostEditURLParams()
#1 /includes/HookContainer/HookContainer.php(159): FlaggedRevsUIHooks->onArticleUpdateBeforeRedirect()
#2 /extensions/PageForms/includes/PF_AutoeditAPI.php(519): MediaWiki\HookContainer\HookContainer->run()
#3 /extensions/PageForms/includes/PF_AutoeditAPI.php(1032): PFAutoeditAPI->doStore()
#4 /extensions/PageForms/includes/PF_AutoeditAPI.php(130): PFAutoeditAPI->doAction()
#5 /extensions/PageForms/specials/PF_FormEdit.php(113): PFAutoeditAPI->execute()
#6 /extensions/PageForms/specials/PF_FormEdit.php(54): PFFormEdit->printForm()
#7 /includes/specialpage/SpecialPage.php(728): PFFormEdit->execute()
#8 /includes/specialpage/SpecialPageFactory.php(1717): MediaWiki\SpecialPage\SpecialPage->run()
#9 /includes/actions/ActionEntryPoint.php(504): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#10 /includes/actions/ActionEntryPoint.php(146): MediaWiki\Actions\ActionEntryPoint->performRequest()
#11 /includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()
#12 /index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#13 {main}

I have reported this here since the hook definition in MW core [1] says it should be a string, if this is the wrong place to report this issue please move it to the right place.

[0] https://gerrit.wikimedia.org/g/mediawiki/extensions/PageForms/+/0b984cc02ff91bffb9b92c83b7d6814584a31a68/includes/PF_AutoeditAPI.php#519
[1] https://gerrit.wikimedia.org/g/mediawiki/core/+/509a2491ef87e50a32bfdcc987bfc3e2cefb5598/includes/Hook/ArticleUpdateBeforeRedirectHook.php#26

Event Timeline

Change #1221083 had a related patch set uploaded (by Yaron Koren; author: Yaron Koren):

[mediawiki/extensions/PageForms@master] Change ArticleUpdateBeforeRedirect params from null to blank

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

I believe a couple lines down in the case EditPage::AS_SUCCESS_UPDATE: case there is another instance where a null could be put into a value that should be a string in the hook. Would be something like

-				$sectionanchor = $resultDetails['sectionanchor'] ?? null;
+				$sectionanchor = $resultDetails['sectionanchor'] ?? '';

For the part you fixed in the patch I believe that works though.

@SomeRandomDeveloper - does this patch fix the problem?

Yes, it does, thanks!
Though as noted in the comment above, it might be worth fixing the other instance of this issue as well

Change #1221083 merged by jenkins-bot:

[mediawiki/extensions/PageForms@master] Change ArticleUpdateBeforeRedirect params from null to blank

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

Yaron_Koren claimed this task.

@SomeRandomDeveloper and @FO-nTTaX - thanks to both of you for your help. I believe this problem is fully fixed now!