Page MenuHomePhabricator

[Regression] UnknownAction hook problem: the hook should pass the raw action value and not the one core uses ("nosuchaction")
Closed, ResolvedPublic

Description

I found (at least) in Extension:WikiArticleFeeds the problem, that an url like

&action=feed&feed=atom

calls the hook with value action == nosuchaction .

This is a deviation from previous behavious (I would say, serious).
Pls. correct me, if I am wrong, or can you correct the problem in core ?


Version: 1.20.x
Severity: blocker
URL: https://www.mediawiki.org/wiki/Extension:WikiArticleFeeds

Details

Reference
bz34203

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 12:11 AM
bzimport set Reference to bz34203.
bzimport added a subscriber: Unknown Object (MLST).

Analysis part:

when using the (admittedly) deprecated, but still present UnknownAction hook, it returns currently 'nosuchaction' - and Extensions which hooks on an &action=feed value will fail

because

in wiki.php getAction() is called, and getActionName() returns $act == 'nosuchaction' . This overwrites the &action=xyz value the hook should have a chance to see, instead, it passes 'nosuchaction' to the hook.

wiki.php:

when called with &action=feed (as example; I added a debug output)

480 $act = $this->getAction(); / $act = 'nosuchaction' and overwriting our 'feed' value
480a wfDebug( "Wiki:performAction:act = $act\n" );
481
482 $action = Action::factory( $act, $page );
483 if ( $action instanceof Action ) {
484 $action->show();
485 wfProfileOut( METHOD );
486 return;
487 }
488
488a
the hook sees 'nosuchaction' instead of 'feed'
489 if ( wfRunHooks( 'UnknownAction', array( $act, $page ) ) ) {
490 $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
491 }
492

I am not courageous and competent enough to fix this in this very core part.
Please can anyone of your core developers fix it ?

The debug log proves my analysis:

GET /phase3/index.php?title=Sandbox2&action=feed&feed=rss
Wiki:performAction:act = nosuchaction <<< wrong; should be 'feed'

The problem is in Article:getActionName() , which returns 'nosuchaction' but the UnknownAction hook should be called _before_ an (internally) unknown action value gets overwritten.

Link added as reference on https://www.mediawiki.org/wiki/Manual:Hooks/UnknownAction - so that potential users of the deprecated hook are pointed to here.