Merge "Fix typos in MessageCache"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 28 May 2019 21:46:27 +0000 (21:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 28 May 2019 21:46:27 +0000 (21:46 +0000)
RELEASE-NOTES-1.34
includes/EditPage.php
includes/MovePage.php
includes/Title.php
includes/media/BmpHandler.php
includes/preferences/MultiUsernameFilter.php
includes/specials/SpecialMovepage.php
tests/phpunit/includes/MovePageTest.php
tests/phpunit/includes/TitleMethodsTest.php
tests/phpunit/includes/TitleTest.php

index 3cc300c..7364d9a 100644 (file)
@@ -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 ===
 * …
index 47a8b5b..ab7d6bb 100644 (file)
@@ -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
index d045355..832e24a 100644 (file)
@@ -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' );
                }
index c4fe858..3d262d5 100644 (file)
@@ -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 );
index 09cbdac..9a9c0a6 100644 (file)
@@ -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' ];
        }
 
index 2d8ae3c..f1c095e 100644 (file)
@@ -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[]
index b561e5b..507cd45 100644 (file)
@@ -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 );
                                        }
index db9d2ab..9166666 100644 (file)
@@ -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
index abd70b2..77d6f59 100644 (file)
@@ -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();
index c46f69b..d6c3401 100644 (file)
@@ -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 );