Brion VIBBER has uploaded a new change for review.

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

Change subject: Revert "Make an empty "?action=" parameter default to "view""
......................................................................

Revert "Make an empty "?action=" parameter default to "view""

Breaks all non-view actions on dev wikis, something's not right with the patch.

This reverts commit a90b7ea969b4332a6229be1c4160190a3ec79200.

Change-Id: Ib9a5eb07ef48716df193fbb62a86c13e5c80dafd
---
M includes/MediaWiki.php
M includes/actions/Action.php
M includes/skins/SkinTemplate.php
M tests/phpunit/includes/actions/ActionTest.php
4 files changed, 14 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/00/166200/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index 8ec6d35..87468bd 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -59,7 +59,7 @@
                $request = $this->context->getRequest();
                $curid = $request->getInt( 'curid' );
                $title = $request->getVal( 'title' );
-               $action = $this->getAction();
+               $action = $request->getVal( 'action', 'view' );
 
                if ( $request->getCheck( 'search' ) ) {
                        // Compatibility with old search URLs which didn't use 
Special:Search
@@ -229,7 +229,7 @@
                                throw new BadTitleError();
                        }
                // Redirect loops, no title in URL, $wgUsePathInfo URLs, and 
URLs with a variant
-               } elseif ( $this->getAction() === 'view' && 
!$request->wasPosted()
+               } elseif ( $request->getVal( 'action', 'view' ) == 'view' && 
!$request->wasPosted()
                        && ( $request->getVal( 'title' ) === null
                                || $title->getPrefixedDBkey() != 
$request->getVal( 'title' ) )
                        && !count( $request->getValueNames( array( 'action', 
'title' ) ) )
@@ -330,7 +330,7 @@
 
                // Namespace might change when using redirects
                // Check for redirects ...
-               $action = $this->getAction();
+               $action = $request->getVal( 'action', 'view' );
                $file = ( $title->getNamespace() == NS_FILE ) ? 
$article->getFile() : null;
                if ( ( $action == 'view' || $action == 'render' ) // ... for 
actions that show content
                        && !$request->getVal( 'oldid' ) // ... and are not old 
revisions
@@ -416,7 +416,7 @@
                        return;
                }
 
-               if ( wfRunHooks( 'UnknownAction', array( $this->getAction(), 
$page ) ) ) {
+               if ( wfRunHooks( 'UnknownAction', array( $request->getVal( 
'action', 'view' ), $page ) ) ) {
                        $output->setStatusCode( 404 );
                        $output->showErrorPage( 'nosuchaction', 
'nosuchactiontext' );
                }
@@ -489,7 +489,8 @@
                $request = $this->context->getRequest();
 
                // Send Ajax requests to the Ajax dispatcher.
-               if ( $this->config->get( 'UseAjax' ) && $this->getAction() === 
'ajax' ) {
+               if ( $this->config->get( 'UseAjax' ) && $request->getVal( 
'action', 'view' ) == 'ajax' ) {
+
                        // Set a dummy title, because $wgTitle == null might 
break things
                        $title = Title::makeTitle( NS_MAIN, 'AJAX' );
                        $this->context->setTitle( $title );
diff --git a/includes/actions/Action.php b/includes/actions/Action.php
index f9840ad..8d11d90 100644
--- a/includes/actions/Action.php
+++ b/includes/actions/Action.php
@@ -142,7 +142,7 @@
                // Trying to get a WikiPage for NS_SPECIAL etc. will result
                // in WikiPage::factory throwing "Invalid or virtual namespace 
-1 given."
                // For SpecialPages et al, default to action=view.
-               if ( $actionName === '' || !$context->canUseWikiPage() ) {
+               if ( !$context->canUseWikiPage() ) {
                        return 'view';
                }
 
diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php
index 0bc980a..c1db302 100644
--- a/includes/skins/SkinTemplate.php
+++ b/includes/skins/SkinTemplate.php
@@ -844,7 +844,7 @@
                );
 
                // parameters
-               $action = Action::getActionName( $this );
+               $action = $request->getVal( 'action', 'view' );
 
                $userCanRead = $title->quickUserCan( 'read', $user );
 
diff --git a/tests/phpunit/includes/actions/ActionTest.php 
b/tests/phpunit/includes/actions/ActionTest.php
index 429de4e..cc6fb11 100644
--- a/tests/phpunit/includes/actions/ActionTest.php
+++ b/tests/phpunit/includes/actions/ActionTest.php
@@ -57,6 +57,8 @@
                        // Null and non-existing values
                        array( 'null', null ),
                        array( 'undeclared', null ),
+                       array( '', null ),
+                       array( false, null ),
                );
        }
 
@@ -127,37 +129,20 @@
                $this->assertType( $expected ?: 'null', $action );
        }
 
-       public function emptyActionProvider() {
-               return array(
-                       array( null ),
-                       array( false ),
-                       array( '' ),
-               );
-       }
-
-       /**
-        * @dataProvider emptyActionProvider
-        */
-       public function testEmptyAction_doesNotExist( $requestedAction ) {
-               $exists = Action::exists( $requestedAction );
+       public function testNull_doesNotExist() {
+               $exists = Action::exists( null );
 
                $this->assertFalse( $exists );
        }
 
-       /**
-        * @dataProvider emptyActionProvider
-        */
-       public function testEmptyAction_defaultsToView() {
+       public function testNull_defaultsToView() {
                $context = $this->getContext( null );
                $actionName = Action::getActionName( $context );
 
                $this->assertEquals( 'view', $actionName );
        }
 
-       /**
-        * @dataProvider emptyActionProvider
-        */
-       public function testEmptyAction_canNotBeInstantiated() {
+       public function testNull_canNotBeInstantiated() {
                $page = $this->getPage();
                $action = Action::factory( null, $page );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/166200
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9a5eb07ef48716df193fbb62a86c13e5c80dafd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <br...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to