Merge "Migrate image descriptions from image_comment_temp"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 3 Oct 2018 01:23:54 +0000 (01:23 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 3 Oct 2018 01:23:54 +0000 (01:23 +0000)
includes/cache/MessageCache.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/IDatabase.php
includes/page/Article.php
includes/poolcounter/PoolWorkArticleView.php
languages/Language.php
resources/src/mediawiki.rcfilters/styles/mw.rcfilters.ui.ItemMenuOptionWidget.less
tests/phpunit/includes/cache/MessageCacheTest.php
tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php
tests/phpunit/includes/page/ArticleViewTest.php
tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php

index aa929bc..bf2ed2e 100644 (file)
@@ -776,13 +776,12 @@ class MessageCache {
         *   - If boolean and false, create object from the current users language
         *   - If boolean and true, create object from the wikis content language
         *   - If language object, use it as given
-        * @param bool $isFullKey Specifies whether $key is a two part key "msg/lang".
         *
         * @throws MWException When given an invalid key
         * @return string|bool False if the message doesn't exist, otherwise the
         *   message (which can be empty)
         */
-       function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) {
+       function get( $key, $useDB = true, $langcode = true ) {
                if ( is_int( $key ) ) {
                        // Fix numerical strings that somehow become ints
                        // on their way here
@@ -794,13 +793,6 @@ class MessageCache {
                        return false;
                }
 
-               // For full keys, get the language code from the key
-               $pos = strrpos( $key, '/' );
-               if ( $isFullKey && $pos !== false ) {
-                       $langcode = substr( $key, $pos + 1 );
-                       $key = substr( $key, 0, $pos );
-               }
-
                // Normalise title-case input (with some inlining)
                $lckey = self::normalizeKey( $key );
 
index f37364f..5c0a8c7 100644 (file)
@@ -1742,7 +1742,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        $conds = '';
                }
 
-               if ( $conds === '' ) {
+               if ( $conds === '' || $conds === '*' ) {
                        $sql = "SELECT $startOpts $fields $from $useIndex $ignoreIndex $preLimitTail";
                } elseif ( is_string( $conds ) ) {
                        $sql = "SELECT $startOpts $fields $from $useIndex $ignoreIndex " .
index f97db3a..b1582a1 100644 (file)
@@ -670,6 +670,8 @@ interface IDatabase {
         * Escaping of untrusted input used in values of numeric keys should be done via
         * IDatabase::addQuotes()
         *
+        * Use an empty array, string, or '*' to update all rows.
+        *
         * @param string|array $options
         *
         * Optional: Array of query options. Boolean options are specified by
index b6f5dce..4a689d3 100644 (file)
@@ -767,7 +767,9 @@ class Article implements Page {
                                                        $parserOptions,
                                                        $this->getRevIdFetched(),
                                                        $useParserCache,
-                                                       $rev
+                                                       $rev,
+                                                       // permission checking was done earlier via showDeletedRevisionHeader()
+                                                       RevisionRecord::RAW
                                                );
                                                $ok = $poolArticleView->execute();
                                                $error = $poolArticleView->getError();
index 157b508..6e6a574 100644 (file)
@@ -44,6 +44,9 @@ class PoolWorkArticleView extends PoolCounterWork {
        /** @var RevisionRecord|null */
        private $revision = null;
 
+       /** @var int */
+       private $audience;
+
        /** @var RevisionStore */
        private $revisionStore = null;
 
@@ -67,9 +70,10 @@ class PoolWorkArticleView extends PoolCounterWork {
         *   operation.
         * @param RevisionRecord|Content|string|null $revision Revision to render, or null to load it;
         *        may also be given as a wikitext string, or a Content object, for BC.
+        * @param int $audience One of the RevisionRecord audience constants
         */
        public function __construct( WikiPage $page, ParserOptions $parserOptions,
-               $revid, $useParserCache, $revision = null
+               $revid, $useParserCache, $revision = null, $audience = RevisionRecord::FOR_PUBLIC
        ) {
                if ( is_string( $revision ) ) { // BC: very old style call
                        $modelId = $page->getRevision()->getContentModel();
@@ -108,6 +112,7 @@ class PoolWorkArticleView extends PoolCounterWork {
                $this->cacheable = $useParserCache;
                $this->parserOptions = $parserOptions;
                $this->revision = $revision;
+               $this->audience = $audience;
                $this->cacheKey = $this->parserCache->getKey( $page, $parserOptions );
                $keyPrefix = $this->cacheKey ?: wfMemcKey( 'articleview', 'missingcachekey' );
 
@@ -152,8 +157,8 @@ class PoolWorkArticleView extends PoolCounterWork {
 
                $isCurrent = $this->revid === $this->page->getLatest();
 
-               // Bypass audience check for current revision
-               $audience = $isCurrent ? RevisionRecord::RAW : RevisionRecord::FOR_PUBLIC;
+               // The current revision cannot be hidden so we can skip some checks.
+               $audience = $isCurrent ? RevisionRecord::RAW : $this->audience;
 
                if ( $this->revision !== null ) {
                        $rev = $this->revision;
index 5897241..8104b2c 100644 (file)
@@ -703,6 +703,14 @@ class Language {
                        }
 
                        $this->namespaceAliases = $aliases + $convertedNames;
+
+                       # Filter out aliases to namespaces that don't exist, e.g. from extensions
+                       # that aren't loaded here but are included in the l10n cache.
+                       # (array_intersect preserves keys from its first argument)
+                       $this->namespaceAliases = array_intersect(
+                               $this->namespaceAliases,
+                               array_keys( $this->getNamespaces() )
+                       );
                }
 
                return $this->namespaceAliases;
index 1cc48e2..bf855be 100644 (file)
@@ -3,7 +3,6 @@
 @import 'mw.rcfilters.variables';
 
 .mw-rcfilters-ui-itemMenuOptionWidget {
-       min-height: 3.5em;
        padding: 0 0.5em;
        .box-sizing( border-box );
 
                .oo-ui-fieldLayout.oo-ui-fieldLayout-align-inline {
                        // Override margin-top and -bottom rules from FieldLayout
                        margin: 0 !important; /* stylelint-disable-line declaration-no-important */
+
+                       .oo-ui-fieldLayout-body > .oo-ui-fieldLayout-field {
+                               vertical-align: middle;
+                       }
                }
 
                .oo-ui-checkboxInputWidget {
                        // Workaround for IE11 rendering issues. T162098
                        display: block;
-                       padding-top: 1em;
                }
 
                label {
index 1edb935..f6ea680 100644 (file)
@@ -129,25 +129,6 @@ class MessageCacheTest extends MediaWikiLangTestCase {
                $this->assertEquals( $oldText, $messageCache->get( $message ), 'Content restored' );
        }
 
-       /**
-        * There's a fallback case where the message key is given as fully qualified -- this
-        * should ignore the passed $lang and use the language from the key
-        *
-        * @dataProvider provideMessagesForFullKeys
-        */
-       public function testFullKeyBehaviour( $message, $lang, $expectedContent ) {
-               $result = MessageCache::singleton()->get( $message, true, $lang, true );
-               $this->assertEquals( $expectedContent, $result, "Full key message fallback failed." );
-       }
-
-       function provideMessagesForFullKeys() {
-               return [
-                       [ 'MessageCacheTest-FullKeyTest/ru', 'ru', 'ru' ],
-                       [ 'MessageCacheTest-FullKeyTest/ru', 'ab', 'ru' ],
-                       [ 'MessageCacheTest-FullKeyTest/ru/foo', 'ru', false ],
-               ];
-       }
-
        /**
         * @dataProvider provideNormalizeKey
         */
index 0cb35b4..600e0d3 100644 (file)
@@ -674,9 +674,9 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase {
                                "INSERT INTO insert_table " .
                                        "(field_insert,field) " .
                                        "SELECT field_select,field2 " .
-                                       "FROM select_table WHERE *",
+                                       "FROM select_table",
                                "SELECT field_select AS field_insert,field2 AS field " .
-                               "FROM select_table WHERE *   FOR UPDATE",
+                               "FROM select_table      FOR UPDATE",
                                "INSERT INTO insert_table (field_insert,field) VALUES ('0','1')"
                        ],
                        [
@@ -755,7 +755,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase {
                        __METHOD__
                );
                $this->assertLastSqlDb( implode( '; ', [
-                       'SELECT field2 AS field FROM select_table WHERE *   FOR UPDATE',
+                       'SELECT field2 AS field FROM select_table      FOR UPDATE',
                        'BEGIN',
                        "INSERT INTO insert_table (field) VALUES ('" . implode( "'),('", range( 0, 9999 ) ) . "')",
                        "INSERT INTO insert_table (field) VALUES ('" . implode( "'),('", range( 10000, 19999 ) ) . "')",
index d07a9e1..629621e 100644 (file)
@@ -298,6 +298,34 @@ class ArticleViewTest extends MediaWikiTestCase {
                $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
        }
 
+       public function testUnhiddenViewOfDeletedRevision() {
+               $revisions = [];
+               $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ], $revisions );
+               $idA = $revisions[1]->getId();
+
+               $revDelList = new RevDelRevisionList(
+                       RequestContext::getMain(), $page->getTitle(), [ $idA ]
+               );
+               $revDelList->setVisibility( [
+                       'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
+                       'comment' => "Testing",
+               ] );
+
+               $article = new Article( $page->getTitle(), $idA );
+               $context = new DerivativeContext( $article->getContext() );
+               $article->setContext( $context );
+               $context->getOutput()->setTitle( $page->getTitle() );
+               $context->getRequest()->setVal( 'unhide', 1 );
+               $context->setUser( $this->getTestUser( [ 'sysop' ] )->getUser() );
+               $article->view();
+
+               $output = $article->getContext()->getOutput();
+               $this->assertContains( '(rev-deleted-text-view)', $this->getHtml( $output ) );
+
+               $this->assertContains( 'Test A', $this->getHtml( $output ) );
+               $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
+       }
+
        public function testViewMissingPage() {
                $page = $this->getPage( __METHOD__ );
 
index a0beb45..47adfc0 100644 (file)
@@ -164,6 +164,10 @@ class PoolWorkArticleViewTest extends MediaWikiTestCase {
                $work = new PoolWorkArticleView( $page, $options, $rev1->getId(), false, $fakeRev );
                $this->assertFalse( $work->execute() );
 
+               $work = new PoolWorkArticleView( $page, $options, $rev1->getId(), false, $fakeRev,
+                       RevisionRecord::RAW );
+               $this->assertNotFalse( $work->execute() );
+
                // a deleted current revision should still be show
                $fakeRev->setId( $rev2->getId() );
                $work = new PoolWorkArticleView( $page, $options, $rev2->getId(), false, $fakeRev );