From: jenkins-bot Date: Tue, 28 May 2019 21:46:27 +0000 (+0000) Subject: Merge "Fix typos in MessageCache" X-Git-Tag: 1.34.0-rc.0~1569 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=cb1f3f90dd02b74166c863204bc7c3b987283a82;hp=e96c15a521f743749a4cc370be43365be6b27624 Merge "Fix typos in MessageCache" --- diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 3cc300c4bd..7364d9a55c 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -189,6 +189,8 @@ because of Phabricator reports. Use the mediawiki.String module instead. * mw.language.specialCharacters, deprecated in 1.33, has been removed. Use require( 'mediawiki.language.specialCharacters' ) instead. +* EditPage::submit(), deprecated in 1.29, has been removed. Used $this->edit() + directly. * … === Deprecations in 1.34 === @@ -234,7 +236,6 @@ because of Phabricator reports. MovePage::moveSubpagesIfAllowed. * The MWNamespace class is deprecated. Use MediaWikiServices::getNamespaceInfo. * (T62260) Hard deprecate Language::getExtraUserToggles() method. -* … === Other changes in 1.34 === * … diff --git a/includes/EditPage.php b/includes/EditPage.php index 47a8b5b87f..ab7d6bb23b 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -565,14 +565,6 @@ class EditPage { $this->enableApiEditOverride = $enableOverride; } - /** - * @deprecated since 1.29, call edit directly - */ - public function submit() { - wfDeprecated( __METHOD__, '1.29' ); - $this->edit(); - } - /** * This is the function that gets called for "action=edit". It * sets up various member variables, then passes execution to diff --git a/includes/MovePage.php b/includes/MovePage.php index d04535558d..832e24af81 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -46,6 +46,14 @@ class MovePage { $this->newTitle = $newTitle; } + /** + * Check if the user is allowed to perform the move. + * + * @param User $user + * @param string|null $reason To check against summary spam regex. Set to null to skip the check, + * for instance to display errors preemptively before the user has filled in a summary. + * @return Status + */ public function checkPermissions( User $user, $reason ) { $status = new Status(); @@ -63,7 +71,7 @@ class MovePage { } } - if ( EditPage::matchSummarySpamRegex( $reason ) !== false ) { + if ( $reason !== null && EditPage::matchSummarySpamRegex( $reason ) !== false ) { // This is kind of lame, won't display nice $status->fatal( 'spamprotectiontext' ); } diff --git a/includes/Title.php b/includes/Title.php index c4fe858ac8..3d262d51fc 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3429,6 +3429,8 @@ class Title implements LinkTarget, IDBAccessObject { * @return array|bool True on success, getUserPermissionsErrors()-like array on failure */ public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) { + wfDeprecated( __METHOD__, '1.25' ); + global $wgUser; if ( !( $nt instanceof Title ) ) { @@ -3465,6 +3467,8 @@ class Title implements LinkTarget, IDBAccessObject { public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true, array $changeTags = [] ) { + wfDeprecated( __METHOD__, '1.25' ); + global $wgUser; $mp = new MovePage( $this, $nt ); @@ -3495,26 +3499,10 @@ class Title implements LinkTarget, IDBAccessObject { public function moveSubpages( $nt, $auth = true, $reason = '', $createRedirect = true, array $changeTags = [] ) { - // Check permissions - if ( !$this->userCan( 'move-subpages' ) ) { - return [ - [ 'cant-move-subpages' ], - ]; - } - // Do the source and target namespaces support subpages? - $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo(); - if ( !$nsInfo->hasSubpages( $this->mNamespace ) ) { - return [ - [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $this->mNamespace ) ], - ]; - } - if ( !$nsInfo->hasSubpages( $nt->getNamespace() ) ) { - return [ - [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $nt->getNamespace() ) ], - ]; - } + wfDeprecated( __METHOD__, '1.34' ); global $wgUser; + $mp = new MovePage( $this, $nt ); $method = $auth ? 'moveSubpagesIfAllowed' : 'moveSubpages'; $result = $mp->$method( $wgUser, $reason, $createRedirect, $changeTags ); @@ -3592,6 +3580,8 @@ class Title implements LinkTarget, IDBAccessObject { * @return bool */ public function isValidMoveTarget( $nt ) { + wfDeprecated( __METHOD__, '1.25' ); + # Is it an existing file? if ( $nt->getNamespace() == NS_FILE ) { $file = wfLocalFile( $nt ); diff --git a/includes/media/BmpHandler.php b/includes/media/BmpHandler.php index 09cbdac23f..9a9c0a6f19 100644 --- a/includes/media/BmpHandler.php +++ b/includes/media/BmpHandler.php @@ -39,12 +39,12 @@ class BmpHandler extends BitmapHandler { /** * Render files as PNG * - * @param string $text + * @param string $ext * @param string $mime * @param array|null $params * @return array */ - public function getThumbType( $text, $mime, $params = null ) { + public function getThumbType( $ext, $mime, $params = null ) { return [ 'png', 'image/png' ]; } diff --git a/includes/preferences/MultiUsernameFilter.php b/includes/preferences/MultiUsernameFilter.php index 2d8ae3c033..f1c095e600 100644 --- a/includes/preferences/MultiUsernameFilter.php +++ b/includes/preferences/MultiUsernameFilter.php @@ -67,7 +67,7 @@ class MultiUsernameFilter implements Filter { } /** - * Splits a newline separated list of user ids into a + * Splits a newline separated list of user ids into an array. * * @param string $str * @return int[] diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index b561e5b61c..507cd450fe 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -170,6 +170,8 @@ class MovePageForm extends UnlistedSpecialPage { $deleteAndMove = false; $moveOverShared = false; + $user = $this->getUser(); + $newTitle = $this->newTitle; if ( !$newTitle ) { @@ -180,14 +182,14 @@ class MovePageForm extends UnlistedSpecialPage { # If a title was supplied, probably from the move log revert # link, check for validity. We can then show some diagnostic # information and save a click. - $newerr = $this->oldTitle->isValidMoveOperation( $newTitle ); - if ( is_array( $newerr ) ) { - $err = $newerr; + $mp = new MovePage( $this->oldTitle, $newTitle ); + $status = $mp->isValidMove(); + $status->merge( $mp->checkPermissions( $user, null ) ); + if ( $status->getErrors() ) { + $err = $status->getErrorsArray(); } } - $user = $this->getUser(); - if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists' && $newTitle->quickUserCan( 'delete', $user ) ) { @@ -741,14 +743,15 @@ class MovePageForm extends UnlistedSpecialPage { continue; } + $mp = new MovePage( $oldSubpage, $newSubpage ); # This was copy-pasted from Renameuser, bleh. - if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) { + if ( $newSubpage->exists() && !$mp->isValidMove()->isOk() ) { $link = $linkRenderer->makeKnownLink( $newSubpage ); $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped(); } else { - $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect ); + $status = $mp->moveIfAllowed( $user, $this->reason, $createRedirect ); - if ( $success === true ) { + if ( $status->isOK() ) { if ( $this->fixRedirects ) { DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage ); } diff --git a/tests/phpunit/includes/MovePageTest.php b/tests/phpunit/includes/MovePageTest.php index db9d2ab8bc..9166666543 100644 --- a/tests/phpunit/includes/MovePageTest.php +++ b/tests/phpunit/includes/MovePageTest.php @@ -47,29 +47,6 @@ class MovePageTest extends MediaWikiTestCase { ]; } - /** - * Integration test to catch regressions like T74870. Taken and modified - * from SemanticMediaWiki - * - * @covers Title::moveTo - */ - public function testTitleMoveCompleteIntegrationTest() { - $oldTitle = Title::newFromText( 'Help:Some title' ); - WikiPage::factory( $oldTitle )->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() - ); - } - /** * Test for the move operation being aborted via the TitleMove hook * @covers MovePage::move diff --git a/tests/phpunit/includes/TitleMethodsTest.php b/tests/phpunit/includes/TitleMethodsTest.php index abd70b2524..77d6f59d21 100644 --- a/tests/phpunit/includes/TitleMethodsTest.php +++ b/tests/phpunit/includes/TitleMethodsTest.php @@ -437,6 +437,31 @@ class TitleMethodsTest extends MediaWikiLangTestCase { $this->assertSame( $expected, $title->getLinkURL( $query, $query2, $proto ) ); } + /** + * Integration test to catch regressions like T74870. Taken and modified + * from SemanticMediaWiki + * + * @covers Title::moveTo + */ + public function testTitleMoveCompleteIntegrationTest() { + $this->hideDeprecated( 'Title::moveTo' ); + + $oldTitle = Title::newFromText( 'Help:Some title' ); + WikiPage::factory( $oldTitle )->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() + ); + } + function tearDown() { Title::clearCaches(); parent::tearDown(); diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index c46f69b2ef..d6c34014f7 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -295,6 +295,8 @@ class TitleTest extends MediaWikiTestCase { * @covers Title::isValidMoveOperation */ public function testIsValidMoveOperation( $source, $target, $expected ) { + $this->hideDeprecated( 'Title::isValidMoveOperation' ); + $this->setMwGlobals( 'wgContentHandlerUseDB', false ); $title = Title::newFromText( $source ); $nt = Title::newFromText( $target );