Merge "Add Unicode to ICU mappings for versions 58 and 59"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 26 Oct 2017 18:48:41 +0000 (18:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 26 Oct 2017 18:48:41 +0000 (18:48 +0000)
RELEASE-NOTES-1.31
includes/actions/RawAction.php
includes/libs/filebackend/SwiftFileBackend.php
includes/page/Article.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/RevisionIntegrationTest.php
tests/phpunit/includes/page/ArticleTest.php

index 042af6e..60dd495 100644 (file)
@@ -57,6 +57,9 @@ changes to languages because of Phabricator reports.
 * mw.page (deprecated in 1.30) was removed.
 * Article::getLastPurgeTimestamp(), WikiPage::getLastPurgeTimestamp(), and the
   related WikiPage::PURGE_* constants, deprecated in 1.29, were removed.
+* The Article::selectFields(), Article::onArticleCreate(),
+  Article::onArticleDelete(), and Article::onArticleEdit() methods, deprecated
+  in 1.24, were removed.
 
 == Compatibility ==
 MediaWiki 1.31 requires PHP 5.5.9 or later. There is experimental support for
index d8c8bc3..be10ae4 100644 (file)
@@ -236,7 +236,13 @@ class RawAction extends FormlessAction {
                        }
                }
 
-               $allowedCTypes = [ 'text/x-wiki', 'text/javascript', 'text/css', 'application/x-zope-edit' ];
+               $allowedCTypes = [
+                       'text/x-wiki',
+                       'text/javascript',
+                       'text/css',
+                       'application/x-zope-edit',
+                       'application/json'
+               ];
                if ( $ctype == '' || !in_array( $ctype, $allowedCTypes ) ) {
                        $ctype = 'text/x-wiki';
                }
index 4212ff5..e54e8da 100644 (file)
@@ -714,7 +714,8 @@ class SwiftFileBackend extends FileBackendStore {
 
                /** @noinspection PhpUnusedLocalVariableInspection */
                $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
-               $this->logger->error( __METHOD__ . ": $path was not stored with SHA-1 metadata." );
+               $this->logger->error( __METHOD__ . ": {path} was not stored with SHA-1 metadata.",
+                       [ 'path' => $path ] );
 
                $objHdrs['x-object-meta-sha1base36'] = false;
 
index da8fe88..3767ecc 100644 (file)
@@ -2638,45 +2638,5 @@ class Article implements Page {
                return $handler->getAutoDeleteReason( $title, $hasHistory );
        }
 
-       /**
-        * @return array
-        *
-        * @deprecated since 1.24, use WikiPage::selectFields() instead
-        */
-       public static function selectFields() {
-               wfDeprecated( __METHOD__, '1.24' );
-               return WikiPage::selectFields();
-       }
-
-       /**
-        * @param Title $title
-        *
-        * @deprecated since 1.24, use WikiPage::onArticleCreate() instead
-        */
-       public static function onArticleCreate( $title ) {
-               wfDeprecated( __METHOD__, '1.24' );
-               WikiPage::onArticleCreate( $title );
-       }
-
-       /**
-        * @param Title $title
-        *
-        * @deprecated since 1.24, use WikiPage::onArticleDelete() instead
-        */
-       public static function onArticleDelete( $title ) {
-               wfDeprecated( __METHOD__, '1.24' );
-               WikiPage::onArticleDelete( $title );
-       }
-
-       /**
-        * @param Title $title
-        *
-        * @deprecated since 1.24, use WikiPage::onArticleEdit() instead
-        */
-       public static function onArticleEdit( $title ) {
-               wfDeprecated( __METHOD__, '1.24' );
-               WikiPage::onArticleEdit( $title );
-       }
-
        // ******
 }
index 63d05a0..c422b51 100644 (file)
@@ -6,69 +6,62 @@
  */
 class BlockTest extends MediaWikiLangTestCase {
 
-       /** @var Block */
-       private $block;
-       private $madeAt;
-
-       /* variable used to save up the blockID we insert in this test suite */
-       private $blockId;
-
-       function addDBData() {
-               $user = User::newFromName( 'UTBlockee' );
-               if ( $user->getId() == 0 ) {
-                       $user->addToDatabase();
-                       TestUser::setPasswordForUser( $user, 'UTBlockeePassword' );
-
-                       $user->saveSettings();
-               }
+       /**
+        * @return User
+        */
+       private function getUserForBlocking() {
+               $testUser = $this->getMutableTestUser();
+               $user = $testUser->getUser();
+               $user->addToDatabase();
+               TestUser::setPasswordForUser( $user, 'UTBlockeePassword' );
+               $user->saveSettings();
+               return $user;
+       }
 
+       /**
+        * @param User $user
+        *
+        * @return Block
+        * @throws MWException
+        */
+       private function addBlockForUser( User $user ) {
                // Delete the last round's block if it's still there
-               $oldBlock = Block::newFromTarget( 'UTBlockee' );
+               $oldBlock = Block::newFromTarget( $user->getName() );
                if ( $oldBlock ) {
                        // An old block will prevent our new one from saving.
                        $oldBlock->delete();
                }
 
                $blockOptions = [
-                       'address' => 'UTBlockee',
+                       'address' => $user->getName(),
                        'user' => $user->getId(),
                        'reason' => 'Parce que',
                        'expiry' => time() + 100500,
                ];
-               $this->block = new Block( $blockOptions );
-               $this->madeAt = wfTimestamp( TS_MW );
+               $block = new Block( $blockOptions );
 
-               $this->block->insert();
+               $block->insert();
                // save up ID for use in assertion. Since ID is an autoincrement,
                // its value might change depending on the order the tests are run.
                // ApiBlockTest insert its own blocks!
-               $newBlockId = $this->block->getId();
-               if ( $newBlockId ) {
-                       $this->blockId = $newBlockId;
-               } else {
+               if ( !$block->getId() ) {
                        throw new MWException( "Failed to insert block for BlockTest; old leftover block remaining?" );
                }
 
                $this->addXffBlocks();
-       }
 
-       /**
-        * debug function : dump the ipblocks table
-        */
-       function dumpBlocks() {
-               $v = $this->db->select( 'ipblocks', '*' );
-               print "Got " . $v->numRows() . " rows. Full dump follow:\n";
-               foreach ( $v as $row ) {
-                       print_r( $row );
-               }
+               return $block;
        }
 
        /**
         * @covers Block::newFromTarget
         */
        public function testINewFromTargetReturnsCorrectBlock() {
+               $user = $this->getUserForBlocking();
+               $block = $this->addBlockForUser( $user );
+
                $this->assertTrue(
-                       $this->block->equals( Block::newFromTarget( 'UTBlockee' ) ),
+                       $block->equals( Block::newFromTarget( $user->getName() ) ),
                        "newFromTarget() returns the same block as the one that was made"
                );
        }
@@ -77,8 +70,11 @@ class BlockTest extends MediaWikiLangTestCase {
         * @covers Block::newFromID
         */
        public function testINewFromIDReturnsCorrectBlock() {
+               $user = $this->getUserForBlocking();
+               $block = $this->addBlockForUser( $user );
+
                $this->assertTrue(
-                       $this->block->equals( Block::newFromID( $this->blockId ) ),
+                       $block->equals( Block::newFromID( $block->getId() ) ),
                        "newFromID() returns the same block as the one that was made"
                );
        }
@@ -87,8 +83,12 @@ class BlockTest extends MediaWikiLangTestCase {
         * per T28425
         */
        public function testBug26425BlockTimestampDefaultsToTime() {
+               $user = $this->getUserForBlocking();
+               $block = $this->addBlockForUser( $user );
+               $madeAt = wfTimestamp( TS_MW );
+
                // delta to stop one-off errors when things happen to go over a second mark.
-               $delta = abs( $this->madeAt - $this->block->mTimestamp );
+               $delta = abs( $madeAt - $block->mTimestamp );
                $this->assertLessThan(
                        2,
                        $delta,
@@ -105,9 +105,12 @@ class BlockTest extends MediaWikiLangTestCase {
         * @covers Block::newFromTarget
         */
        public function testBug29116NewFromTargetWithEmptyIp( $vagueTarget ) {
-               $block = Block::newFromTarget( 'UTBlockee', $vagueTarget );
+               $user = $this->getUserForBlocking();
+               $initialBlock = $this->addBlockForUser( $user );
+               $block = Block::newFromTarget( $user->getName(), $vagueTarget );
+
                $this->assertTrue(
-                       $this->block->equals( $block ),
+                       $initialBlock->equals( $block ),
                        "newFromTarget() returns the same block as the one that was made when "
                                . "given empty vagueTarget param " . var_export( $vagueTarget, true )
                );
@@ -351,6 +354,9 @@ class BlockTest extends MediaWikiLangTestCase {
         * @covers Block::chooseBlock
         */
        public function testBlocksOnXff( $xff, $exCount, $exResult ) {
+               $user = $this->getUserForBlocking();
+               $this->addBlockForUser( $user );
+
                $list = array_map( 'trim', explode( ',', $xff ) );
                $xffblocks = Block::getBlocksForIPList( $list, true );
                $this->assertEquals( $exCount, count( $xffblocks ), 'Number of blocks for ' . $xff );
@@ -411,8 +417,11 @@ class BlockTest extends MediaWikiLangTestCase {
        }
 
        public function testSystemBlocks() {
+               $user = $this->getUserForBlocking();
+               $this->addBlockForUser( $user );
+
                $blockOptions = [
-                       'address' => 'UTBlockee',
+                       'address' => $user->getName(),
                        'reason' => 'test system block',
                        'timestamp' => wfTimestampNow(),
                        'expiry' => $this->db->getInfinity(),
@@ -438,4 +447,5 @@ class BlockTest extends MediaWikiLangTestCase {
                        $this->assertSame( 'Cannot autoblock from a system block', $ex->getMessage() );
                }
        }
+
 }
index 9dcd0cf..10186ed 100644 (file)
@@ -151,6 +151,78 @@ class RevisionIntegrationTest extends MediaWikiTestCase {
                $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
        }
 
+       /**
+        * @covers Revision::insertOn
+        */
+       public function testInsertOn_success() {
+               $parentId = $this->testPage->getLatest();
+
+               // If an ExternalStore is set don't use it.
+               $this->setMwGlobals( 'wgDefaultExternalStore', false );
+
+               $rev = new Revision( [
+                       'page' => $this->testPage->getId(),
+                       'title' => $this->testPage->getTitle(),
+                       'text' => 'Revision Text',
+                       'comment' => 'Revision comment',
+               ] );
+
+               $revId = $rev->insertOn( wfGetDB( DB_MASTER ) );
+
+               $this->assertInternalType( 'integer', $revId );
+               $this->assertInternalType( 'integer', $rev->getTextId() );
+               $this->assertSame( $revId, $rev->getId() );
+
+               $this->assertSelect(
+                       'text',
+                       [ 'old_id', 'old_text' ],
+                       "old_id = {$rev->getTextId()}",
+                       [ [ strval( $rev->getTextId() ), 'Revision Text' ] ]
+               );
+               $this->assertSelect(
+                       'revision',
+                       [
+                               'rev_id',
+                               'rev_page',
+                               'rev_text_id',
+                               'rev_user',
+                               'rev_minor_edit',
+                               'rev_deleted',
+                               'rev_len',
+                               'rev_parent_id',
+                               'rev_sha1',
+                       ],
+                       "rev_id = {$rev->getId()}",
+                       [ [
+                               strval( $rev->getId() ),
+                               strval( $this->testPage->getId() ),
+                               strval( $rev->getTextId() ),
+                               '0',
+                               '0',
+                               '0',
+                               '13',
+                               strval( $parentId ),
+                               's0ngbdoxagreuf2vjtuxzwdz64n29xm',
+                       ] ]
+               );
+       }
+
+       /**
+        * @covers Revision::insertOn
+        */
+       public function testInsertOn_exceptionOnNoPage() {
+               // If an ExternalStore is set don't use it.
+               $this->setMwGlobals( 'wgDefaultExternalStore', false );
+               $this->setExpectedException(
+                       MWException::class,
+                       "Cannot insert revision: page ID must be nonzero"
+               );
+
+               $rev = new Revision( [] );
+
+               $rev->insertOn( wfGetDB( DB_MASTER ) );
+       }
+
        /**
         * @covers Revision::newFromTitle
         */
index 7d0813d..df4a281 100644 (file)
@@ -54,26 +54,4 @@ class ArticleTest extends MediaWikiTestCase {
                $this->assertEquals( -8, $this->article->ext_someNewProperty,
                        "Article get/set magic on update to new field" );
        }
-
-       /**
-        * Checks for the existence of the backwards compatibility static functions
-        * (forwarders to WikiPage class)
-        *
-        * @covers Article::selectFields
-        * @covers Article::onArticleCreate
-        * @covers Article::onArticleDelete
-        * @covers Article::onArticleEdit
-        */
-       public function testStaticFunctions() {
-               $this->hideDeprecated( 'Article::selectFields' );
-
-               $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
-                       "Article static functions" );
-               $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
-                       "Article static functions" );
-               $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
-                       "Article static functions" );
-               $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
-                       "Article static functions" );
-       }
 }