Merge "RCFilters: Only show 'no filters' when actually none were found"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 10 Jul 2017 19:22:15 +0000 (19:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 10 Jul 2017 19:22:15 +0000 (19:22 +0000)
24 files changed:
includes/MergeHistory.php
includes/StubObject.php
includes/actions/Action.php
includes/cache/LinkBatch.php
includes/cache/localisation/LocalisationCache.php
includes/content/WikiTextStructure.php
includes/diff/DairikiDiff.php
includes/filerepo/file/LocalFile.php
includes/installer/CliInstaller.php
includes/installer/LocalSettingsGenerator.php
includes/installer/WebInstaller.php
includes/libs/GenericArrayObject.php
includes/libs/MemoizedCallable.php
includes/libs/xmp/XMP.php
includes/logging/LogEntry.php
includes/logging/LogEventsList.php
includes/resourceloader/ResourceLoaderSkinModule.php
includes/search/PerRowAugmentor.php
includes/search/SearchIndexFieldDefinition.php
includes/site/MediaWikiSite.php
includes/site/Site.php
includes/user/UserRightsProxy.php
includes/utils/FileContentsHasher.php
tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php [new file with mode: 0644]

index cc589c9..48ff97b 100644 (file)
@@ -60,7 +60,6 @@ class MergeHistory {
        protected $revisionsMerged;
 
        /**
-        * MergeHistory constructor.
         * @param Title $source Page from which history will be merged
         * @param Title $dest Page to which history will be merged
         * @param string|bool $timestamp Timestamp up to which history from the source will be merged
index 0210ed9..5208b8f 100644 (file)
@@ -55,8 +55,6 @@ class StubObject {
        protected $params;
 
        /**
-        * Constructor.
-        *
         * @param string $global Name of the global variable.
         * @param string|callable $class Name of the class of the real object
         *                               or a factory function to call
index 844a0d6..88382b6 100644 (file)
@@ -259,8 +259,6 @@ abstract class Action implements MessageLocalizer {
        }
 
        /**
-        * Constructor.
-        *
         * Only public since 1.21
         *
         * @param Page $page
index 57d4581..d8e3c38 100644 (file)
@@ -43,7 +43,6 @@ class LinkBatch {
        protected $caller;
 
        /**
-        * LinkBatch constructor.
         * @param LinkTarget[] $arr Initial items to be added to the batch
         */
        public function __construct( $arr = [] ) {
index d499340..58a67ad 100644 (file)
@@ -183,7 +183,6 @@ class LocalisationCache {
        private $mergeableKeys = null;
 
        /**
-        * Constructor.
         * For constructor parameters, see the documentation in DefaultSettings.php
         * for $wgLocalisationCacheConf.
         *
index afa03b8..aeb96b6 100644 (file)
@@ -59,7 +59,6 @@ class WikiTextStructure {
        ];
 
        /**
-        * WikiTextStructure constructor.
         * @param ParserOutput $parserOutput
         */
        public function __construct( ParserOutput $parserOutput ) {
index a08bd9e..d76af31 100644 (file)
@@ -211,7 +211,6 @@ class Diff {
        protected $bailoutComplexity = 0;
 
        /**
-        * Constructor.
         * Computes diff between sequences of strings.
         *
         * @param string[] $from_lines An array of strings.
index f71e1dc..33177d3 100644 (file)
@@ -215,7 +215,6 @@ class LocalFile extends File {
        }
 
        /**
-        * Constructor.
         * Do not call this except from inside a repo class.
         * @param Title $title
         * @param FileRepo $repo
index af55dbb..6ac78c4 100644 (file)
@@ -47,8 +47,6 @@ class CliInstaller extends Installer {
        ];
 
        /**
-        * Constructor.
-        *
         * @param string $siteName
         * @param string $admin
         * @param array $option
index a9710eb..bdaeaca 100644 (file)
@@ -41,8 +41,6 @@ class LocalSettingsGenerator {
        protected $installer;
 
        /**
-        * Constructor.
-        *
         * @param Installer $installer
         */
        public function __construct( Installer $installer ) {
index c94f0bf..a311ce9 100644 (file)
@@ -130,8 +130,6 @@ class WebInstaller extends Installer {
        protected $currentPageName;
 
        /**
-        * Constructor.
-        *
         * @param WebRequest $request
         */
        public function __construct( WebRequest $request ) {
index 76e23cf..f76d9a2 100644 (file)
@@ -67,7 +67,6 @@ abstract class GenericArrayObject extends ArrayObject {
        }
 
        /**
-        * Constructor.
         * @see ArrayObject::__construct
         *
         * @since 1.20
index 12a5cad..6b4281f 100644 (file)
@@ -46,8 +46,6 @@ class MemoizedCallable {
        private $callableName;
 
        /**
-        * Constructor.
-        *
         * @throws InvalidArgumentException if $callable is not a callable.
         * @param callable $callable Function or method to memoize.
         * @param int $ttl TTL in seconds. Defaults to 3600 (1hr). Capped at 86400 (24h).
index debe869..e12766a 100644 (file)
@@ -130,8 +130,6 @@ class XMPReader implements LoggerAwareInterface {
        private $logger;
 
        /**
-        * Constructor.
-        *
         * Primary job is to initialize the XMLParser
         */
        function __construct( LoggerInterface $logger = null ) {
index e7095f0..fa94fe5 100644 (file)
@@ -437,8 +437,6 @@ class ManualLogEntry extends LogEntryBase {
        protected $legacy = false;
 
        /**
-        * Constructor.
-        *
         * @since 1.19
         * @param string $type
         * @param string $subtype
index a9679bf..22e5b45 100644 (file)
@@ -55,7 +55,6 @@ class LogEventsList extends ContextSource {
        private $linkRenderer;
 
        /**
-        * Constructor.
         * The first two parameters used to be $skin and $out, but now only a context
         * is needed, that's why there's a second unused parameter.
         *
index 1967a95..ca6e59f 100644 (file)
@@ -34,6 +34,7 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule {
        public function getStyles( ResourceLoaderContext $context ) {
                $logo = $this->getLogo( $this->getConfig() );
                $styles = parent::getStyles( $context );
+               $this->normalizeStyles( $styles );
 
                $default = !is_array( $logo ) ? $logo : $logo['1x'];
                $styles['all'][] = '.mw-wiki-logo { background-image: ' .
@@ -66,6 +67,22 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule {
                return $styles;
        }
 
+       /**
+        * Ensure all media keys use array values.
+        *
+        * Normalises arrays returned by the ResourceLoaderFileModule::getStyles() method.
+        *
+        * @param array &$styles Associative array, keys are strings (media queries),
+        *   values are strings or arrays
+        */
+       private function normalizeStyles( &$styles ) {
+               foreach ( $styles as $key => $val ) {
+                       if ( !is_array( $val ) ) {
+                               $styles[$key] = [ $val ];
+                       }
+               }
+       }
+
        /**
         * @param Config $conf
         * @return string|array Single url if no variants are defined
index 8eb8b17..a3979f7 100644 (file)
@@ -12,7 +12,6 @@ class PerRowAugmentor implements ResultSetAugmentor {
        private $rowAugmentor;
 
        /**
-        * PerRowAugmentor constructor.
         * @param ResultAugmentor $augmentor Per-result augmentor to use.
         */
        public function __construct( ResultAugmentor $augmentor ) {
index e3e01e8..87d6344 100644 (file)
@@ -39,7 +39,6 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField {
        private $mergeCallback;
 
        /**
-        * SearchIndexFieldDefinition constructor.
         * @param string $name Field name
         * @param int    $type Index type
         */
index 6734d5f..f31a77d 100644 (file)
@@ -40,8 +40,6 @@ class MediaWikiSite extends Site {
        const PATH_PAGE = 'page_path';
 
        /**
-        * Constructor.
-        *
         * @since 1.21
         *
         * @param string $type
index 28f19f9..31e1590 100644 (file)
@@ -122,8 +122,6 @@ class Site implements Serializable {
        protected $internalId = null;
 
        /**
-        * Constructor.
-        *
         * @since 1.21
         *
         * @param string $type
index 4df73f7..98586e7 100644 (file)
@@ -29,8 +29,6 @@ use Wikimedia\Rdbms\IDatabase;
 class UserRightsProxy {
 
        /**
-        * Constructor.
-        *
         * @see newFromId()
         * @see newFromName()
         * @param IDatabase $db Db connection
index c74b04d..afe9c0a 100644 (file)
@@ -27,9 +27,6 @@ class FileContentsHasher {
        /** @var FileContentsHasher */
        private static $instance;
 
-       /**
-        * Constructor.
-        */
        public function __construct() {
                $this->cache = ObjectCache::getLocalServerInstance( 'hash' );
        }
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
new file mode 100644 (file)
index 0000000..c567698
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @group Database
+ * @group ResourceLoader
+ */
+class ResourceLoaderSkinModuleTest extends PHPUnit_Framework_TestCase {
+
+       public static function provideGetStyles() {
+               return [
+                       [
+                               'parent' => [],
+                               'expected' => [
+                                       'all' => [ '.mw-wiki-logo { background-image: url(/logo.png); }' ],
+                               ],
+                       ],
+                       [
+                               'parent' => [
+                                       'screen' => '.example {}',
+                               ],
+                               'expected' => [
+                                       'screen' => [ '.example {}' ],
+                                       'all' => [ '.mw-wiki-logo { background-image: url(/logo.png); }' ],
+                               ],
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetStyles
+        * @covers ResourceLoaderSkinModule::normalizeStyles
+        * @covers ResourceLoaderSkinModule::getStyles
+        */
+       public function testGetStyles( $parent, $expected ) {
+               $module = $this->getMockBuilder( ResourceLoaderSkinModule::class )
+                       ->disableOriginalConstructor()
+                       ->setMethods( [ 'readStyleFiles' ] )
+                       ->getMock();
+               $module->expects( $this->once() )->method( 'readStyleFiles' )
+                       ->willReturn( $parent );
+               $module->setConfig( new HashConfig( [
+                       'ResourceBasePath' => '/w',
+                       'Logo' => '/logo.png',
+                       'LogoHD' => false,
+               ] ) );
+
+               $ctx = $this->getMockBuilder( ResourceLoaderContext::class )
+                       ->disableOriginalConstructor()->getMock();
+
+               $this->assertEquals(
+                       $module->getStyles( $ctx ),
+                       $expected
+               );
+       }
+
+       /**
+        * @covers ResourceLoaderSkinModule::isKnownEmpty
+        */
+       public function testIsKnownEmpty() {
+               $module = $this->getMockBuilder( ResourceLoaderSkinModule::class )
+                       ->disableOriginalConstructor()->setMethods( null )->getMock();
+               $ctx = $this->getMockBuilder( ResourceLoaderContext::class )
+                       ->disableOriginalConstructor()->getMock();
+
+               $this->assertFalse( $module->isKnownEmpty( $ctx ) );
+       }
+}