From: Kunal Mehta Date: Thu, 5 Feb 2015 18:52:10 +0000 (-0800) Subject: Check $auth parameter in Title::isValidMoveOperation() X-Git-Tag: 1.31.0-rc.0~12482^2~1 X-Git-Url: https://git.heureux-cyclage.org/index.php?a=commitdiff_plain;h=978fc13da2a6272dee1a5924305b1eb48990bcd8;hp=69bd2e54d698f32120940f80f3493479297ecf74;p=lhc%2Fweb%2Fwiklou.git Check $auth parameter in Title::isValidMoveOperation() This also includes the integration test from SemanticMediaWiki that caught this issue. Bug: T74870 Change-Id: I699e14958ee36ec5e86278e5dc0caed2a015d9af --- diff --git a/includes/Title.php b/includes/Title.php index 463f75e728..9a7cd04b22 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3607,7 +3607,7 @@ class Title { * * @deprecated since 1.25, use MovePage's methods instead * @param Title $nt The new title - * @param bool $auth Ignored + * @param bool $auth Whether to check user permissions (uses $wgUser) * @param string $reason Is the log summary of the move, used for spam checking * @return array|bool True on success, getUserPermissionsErrors()-like array on failure */ @@ -3621,10 +3621,13 @@ class Title { } $mp = new MovePage( $this, $nt ); - $errors = wfMergeErrorArrays( - $mp->isValidMove()->getErrorsArray(), - $mp->checkPermissions( $wgUser, $reason )->getErrorsArray() - ); + $errors = $mp->isValidMove()->getErrorsArray(); + if ( $auth ) { + $errors = wfMergeErrorArrays( + $errors, + $mp->checkPermissions( $wgUser, $reason )->getErrorsArray() + ); + } return $errors ? : true; } diff --git a/tests/phpunit/includes/MovePageTest.php b/tests/phpunit/includes/MovePageTest.php index 027b877ce4..9501e452ec 100644 --- a/tests/phpunit/includes/MovePageTest.php +++ b/tests/phpunit/includes/MovePageTest.php @@ -1,5 +1,8 @@ doEditContent( new WikitextContent( 'foo' ), 'bar' ); + $newTitle = Title::newFromText( 'Help:Some other title' ); + $this->assertNull( + WikiPage::factory( $newTitle )->getRevision() + ); + + $this->assertTrue( $oldTitle->moveTo( $newTitle, false, 'test1', true ) ); + $this->assertNotNull( + WikiPage::factory( $oldTitle )->getRevision() + ); + $this->assertNotNull( + WikiPage::factory( $newTitle)->getRevision() + ); + } }