Merge "Setup: Avoid using count() function in any kind of loop(s)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 16 Jan 2019 07:04:36 +0000 (07:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 16 Jan 2019 07:04:36 +0000 (07:04 +0000)
57 files changed:
includes/Block.php
includes/HistoryBlob.php
includes/Revision.php
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryContributors.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryPageProps.php
includes/api/ApiQueryUserContribs.php
includes/clientpool/SquidPurgeClientPool.php
includes/db/DatabaseOracle.php
includes/diff/TextSlotDiffRenderer.php
includes/editpage/TextboxBuilder.php
includes/exception/MWUnknownContentModelException.php
includes/filerepo/LocalRepo.php
includes/filerepo/file/ArchivedFile.php
includes/jobqueue/JobQueue.php
includes/jobqueue/JobQueueDB.php
includes/jobqueue/JobQueueGroup.php
includes/jobqueue/JobQueueRedis.php
includes/libs/filebackend/FileBackend.php
includes/libs/filebackend/filejournal/FileJournal.php
includes/libs/lockmanager/FSLockManager.php
includes/libs/lockmanager/PostgreSqlLockManager.php
includes/libs/lockmanager/QuorumLockManager.php
includes/libs/mime/XmlTypeCheck.php
includes/libs/rdbms/ChronologyProtector.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/DatabaseMysqlBase.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/mail/EmailNotification.php
includes/parser/ParserOptions.php
includes/parser/Preprocessor_DOM.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderImage.php
includes/search/SearchOracle.php
includes/search/SearchSqlite.php
includes/skins/Skin.php
includes/specials/SpecialBlock.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialListgrants.php
includes/specials/SpecialPasswordPolicies.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialSearch.php
includes/specials/SpecialSpecialpages.php
includes/specials/SpecialTrackingCategories.php
includes/user/User.php
includes/widget/search/InterwikiSearchResultSetWidget.php
tests/phpunit/data/resourceloader/def.svg
tests/phpunit/data/resourceloader/def_variantize.svg
tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php
tests/phpunit/includes/media/WebPTest.php
tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderLessVarFileModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
tests/phpunit/includes/upload/UploadStashTest.php

index fb3caf6..7138301 100644 (file)
@@ -1307,7 +1307,7 @@ class Block {
         * @since 1.22
         */
        public static function getBlocksForIPList( array $ipChain, $isAnon, $fromMaster = false ) {
-               if ( !count( $ipChain ) ) {
+               if ( $ipChain === [] ) {
                        return [];
                }
 
@@ -1332,7 +1332,7 @@ class Block {
                        $conds[] = self::getRangeCond( IP::toHex( $ipaddr ) );
                }
 
-               if ( !count( $conds ) ) {
+               if ( $conds === [] ) {
                        return [];
                }
 
@@ -1388,7 +1388,7 @@ class Block {
         * @return Block|null The "best" block from the list
         */
        public static function chooseBlock( array $blocks, array $ipChain ) {
-               if ( !count( $blocks ) ) {
+               if ( $blocks === [] ) {
                        return null;
                } elseif ( count( $blocks ) == 1 ) {
                        return $blocks[0];
index 1d4f6e4..bca6c7e 100644 (file)
@@ -445,8 +445,7 @@ class DiffHistoryBlob implements HistoryBlob {
                        // Already compressed
                        return;
                }
-               if ( !count( $this->mItems ) ) {
-                       // Empty
+               if ( $this->mItems === [] ) {
                        return;
                }
 
@@ -492,7 +491,7 @@ class DiffHistoryBlob implements HistoryBlob {
                $this->mDiffs = [];
                $this->mDiffMap = [];
                foreach ( $sequences as $seq ) {
-                       if ( !count( $seq['diffs'] ) ) {
+                       if ( $seq['diffs'] === [] ) {
                                continue;
                        }
                        if ( $tail === '' ) {
@@ -627,8 +626,7 @@ class DiffHistoryBlob implements HistoryBlob {
         */
        function __sleep() {
                $this->compress();
-               if ( !count( $this->mItems ) ) {
-                       // Empty object
+               if ( $this->mItems === [] ) {
                        $info = false;
                } else {
                        // Take forward differences to improve the compression ratio for sequences
index b0a3ba3..c99f88a 100644 (file)
@@ -846,6 +846,7 @@ class Revision implements IDBAccessObject {
                $user = $this->mRecord->getUser( $audience, $user );
                return $user ? $user->getName() : '';
        }
+
        /**
         * Fetch revision comment if it's available to the specified audience.
         * If the specified audience does not have access to the comment, an
index 7d5f6e2..7b5df50 100644 (file)
@@ -94,7 +94,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                        }
 
                        // no group with the given right(s) exists, no need for a query
-                       if ( !count( $groups ) ) {
+                       if ( $groups === [] ) {
                                $this->getResult()->addIndexedTagName( [ 'query', $this->getModuleName() ], '' );
 
                                return;
index d9fe50b..c92f037 100644 (file)
@@ -277,7 +277,7 @@ abstract class ApiQueryBase extends ApiBase {
                if ( count( $ids ) ) {
                        $ids = $this->filterIDs( [ [ $table, $field ] ], $ids );
 
-                       if ( !count( $ids ) ) {
+                       if ( $ids === [] ) {
                                // Return nothing, no IDs are valid
                                $this->where[] = '0 = 1';
                        } else {
index 642c9ac..a8f970e 100644 (file)
@@ -64,7 +64,7 @@ class ApiQueryContributors extends ApiQueryBase {
                                return $v >= $cont_page;
                        } );
                }
-               if ( !count( $pages ) ) {
+               if ( $pages === [] ) {
                        // Nothing to do
                        return;
                }
index 2ab3c56..8a54c0b 100644 (file)
@@ -721,7 +721,7 @@ class ApiQueryInfo extends ApiQueryBase {
                                $getTitles[] = $t->getTalkPage();
                        }
                }
-               if ( !count( $getTitles ) ) {
+               if ( $getTitles === [] ) {
                        return;
                }
 
@@ -751,7 +751,7 @@ class ApiQueryInfo extends ApiQueryBase {
 
                $pageIds = array_keys( $this->titles );
 
-               if ( !count( $pageIds ) ) {
+               if ( $pageIds === [] ) {
                        return;
                }
 
@@ -768,7 +768,7 @@ class ApiQueryInfo extends ApiQueryBase {
        }
 
        private function getVariantTitles() {
-               if ( !count( $this->titles ) ) {
+               if ( $this->titles === [] ) {
                        return;
                }
                $this->variantTitles = [];
index 2bee698..3258004 100644 (file)
@@ -50,7 +50,7 @@ class ApiQueryPageProps extends ApiQueryBase {
                        $pages = $filteredPages;
                }
 
-               if ( !count( $pages ) ) {
+               if ( $pages === [] ) {
                        # Nothing to do
                        return;
                }
index ed83130..6082617 100644 (file)
@@ -136,7 +136,7 @@ class ApiQueryUserContribs extends ApiQueryBase {
                        // prepareQuery might try to sort by actor and confuse everything.
                        $batchSize = 1;
                } elseif ( isset( $this->params['userids'] ) ) {
-                       if ( !count( $this->params['userids'] ) ) {
+                       if ( $this->params['userids'] === [] ) {
                                $encParamName = $this->encodeParamName( 'userids' );
                                $this->dieWithError( [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName" );
                        }
index 5acac63..3a2a971 100644 (file)
@@ -59,7 +59,7 @@ class SquidPurgeClientPool {
                                        $writeSockets["$clientIndex/$i"] = $socket;
                                }
                        }
-                       if ( !count( $readSockets ) && !count( $writeSockets ) ) {
+                       if ( $readSockets === [] && $writeSockets === [] ) {
                                break;
                        }
 
index 628b47b..6af6de5 100644 (file)
@@ -589,7 +589,7 @@ class DatabaseOracle extends Database {
        public function upsert( $table, array $rows, array $uniqueIndexes, array $set,
                $fname = __METHOD__
        ) {
-               if ( !count( $rows ) ) {
+               if ( $rows === [] ) {
                        return true; // nothing to do
                }
 
index 1cc6646..e2cdd82 100644 (file)
@@ -85,6 +85,7 @@ class TextSlotDiffRenderer extends SlotDiffRenderer {
        public function setLanguage( Language $language ) {
                $this->language = $language;
        }
+
        /**
         * @param int $cutoff
         * @see $wgWikiDiff2MovedParagraphDetectionCutoff
index 81dc78d..354cc61 100644 (file)
@@ -58,7 +58,7 @@ class TextboxBuilder {
         * @return mixed[]
         */
        public function mergeClassesIntoAttributes( array $classes, array $attribs ) {
-               if ( !count( $classes ) ) {
+               if ( $classes === [] ) {
                        return $attribs;
                }
 
index df7111a..9f22815 100644 (file)
@@ -18,6 +18,7 @@ class MWUnknownContentModelException extends MWException {
                        'handle this content model.' );
                $this->modelId = $modelId;
        }
+
        /** @return string */
        public function getModelId() {
                return $this->modelId;
index b3eae90..bb65b0a 100644 (file)
@@ -405,7 +405,7 @@ class LocalRepo extends FileRepo {
         * @return array[] An Array of arrays or iterators of file objects and the hash as key
         */
        function findBySha1s( array $hashes ) {
-               if ( !count( $hashes ) ) {
+               if ( $hashes === [] ) {
                        return []; // empty parameter
                }
 
index 4a84cff..6a3e819 100644 (file)
@@ -169,7 +169,7 @@ class ArchivedFile {
                        $conds['fa_sha1'] = $this->sha1;
                }
 
-               if ( !count( $conds ) ) {
+               if ( $conds === [] ) {
                        throw new MWException( "No specific information for retrieving archived file" );
                }
 
index 3689ba4..4f4728d 100644 (file)
@@ -323,7 +323,7 @@ abstract class JobQueue {
        final public function batchPush( array $jobs, $flags = 0 ) {
                $this->assertNotReadOnly();
 
-               if ( !count( $jobs ) ) {
+               if ( $jobs === [] ) {
                        return; // nothing to do
                }
 
index 9931d83..fa17284 100644 (file)
@@ -214,7 +214,7 @@ class JobQueueDB extends JobQueue {
         * @return void
         */
        public function doBatchPushInternal( IDatabase $dbw, array $jobs, $flags, $method ) {
-               if ( !count( $jobs ) ) {
+               if ( $jobs === [] ) {
                        return;
                }
 
index b103b8e..4853c4a 100644 (file)
@@ -143,7 +143,7 @@ class JobQueueGroup {
                }
 
                $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
-               if ( !count( $jobs ) ) {
+               if ( $jobs === [] ) {
                        return;
                }
 
index b868128..a1ef28b 100644 (file)
@@ -203,7 +203,7 @@ class JobQueueRedis extends JobQueue {
                        }
                }
 
-               if ( !count( $items ) ) {
+               if ( $items === [] ) {
                        return; // nothing to do
                }
 
index 27e6924..06a155a 100644 (file)
@@ -417,7 +417,7 @@ abstract class FileBackend implements LoggerAwareInterface {
                if ( empty( $opts['bypassReadOnly'] ) && $this->isReadOnly() ) {
                        return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly );
                }
-               if ( !count( $ops ) ) {
+               if ( $ops === [] ) {
                        return $this->newStatus(); // nothing to do
                }
 
@@ -436,6 +436,7 @@ abstract class FileBackend implements LoggerAwareInterface {
         * @see FileBackend::doOperations()
         * @param array $ops
         * @param array $opts
+        * @return StatusValue
         */
        abstract protected function doOperationsInternal( array $ops, array $opts );
 
@@ -655,7 +656,7 @@ abstract class FileBackend implements LoggerAwareInterface {
                if ( empty( $opts['bypassReadOnly'] ) && $this->isReadOnly() ) {
                        return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly );
                }
-               if ( !count( $ops ) ) {
+               if ( $ops === [] ) {
                        return $this->newStatus(); // nothing to do
                }
 
@@ -673,6 +674,7 @@ abstract class FileBackend implements LoggerAwareInterface {
        /**
         * @see FileBackend::doQuickOperations()
         * @param array $ops
+        * @return StatusValue
         * @since 1.20
         */
        abstract protected function doQuickOperationsInternal( array $ops );
@@ -819,6 +821,7 @@ abstract class FileBackend implements LoggerAwareInterface {
        /**
         * @see FileBackend::prepare()
         * @param array $params
+        * @return StatusValue
         */
        abstract protected function doPrepare( array $params );
 
@@ -850,6 +853,7 @@ abstract class FileBackend implements LoggerAwareInterface {
        /**
         * @see FileBackend::secure()
         * @param array $params
+        * @return StatusValue
         */
        abstract protected function doSecure( array $params );
 
@@ -883,6 +887,7 @@ abstract class FileBackend implements LoggerAwareInterface {
        /**
         * @see FileBackend::publish()
         * @param array $params
+        * @return StatusValue
         */
        abstract protected function doPublish( array $params );
 
@@ -909,6 +914,7 @@ abstract class FileBackend implements LoggerAwareInterface {
        /**
         * @see FileBackend::clean()
         * @param array $params
+        * @return StatusValue
         */
        abstract protected function doClean( array $params );
 
index 47be4eb..999594b 100644 (file)
@@ -97,7 +97,7 @@ abstract class FileJournal {
         * @return StatusValue
         */
        final public function logChangeBatch( array $entries, $batchId ) {
-               if ( !count( $entries ) ) {
+               if ( $entries === [] ) {
                        return StatusValue::newGood();
                }
 
index f2624e7..019029c 100644 (file)
@@ -169,7 +169,7 @@ class FSLockManager extends LockManager {
                        if ( $this->locksHeld[$path][$type] <= 0 ) {
                                unset( $this->locksHeld[$path][$type] );
                        }
-                       if ( !count( $this->locksHeld[$path] ) ) {
+                       if ( $this->locksHeld[$path] === [] ) {
                                unset( $this->locksHeld[$path] ); // no locks on this path
                                if ( isset( $this->handles[$path] ) ) {
                                        $handlesToClose[] = $this->handles[$path];
index 65c6993..fd3ffa5 100644 (file)
@@ -18,7 +18,7 @@ class PostgreSqlLockManager extends DBLockManager {
 
        protected function doGetLocksOnServer( $lockSrv, array $paths, $type ) {
                $status = StatusValue::newGood();
-               if ( !count( $paths ) ) {
+               if ( $paths === [] ) {
                        return $status; // nothing to lock
                }
 
index 1d2e21a..1ef4642 100644 (file)
@@ -98,7 +98,7 @@ abstract class QuorumLockManager extends LockManager {
                                                $bucket = $this->getBucketFromPath( $path );
                                                $pathsToUnlock[$bucket][$type][] = $path;
                                        }
-                                       if ( !count( $this->locksHeld[$path] ) ) {
+                                       if ( $this->locksHeld[$path] === [] ) {
                                                unset( $this->locksHeld[$path] ); // no SH or EX locks left for key
                                        }
                                }
@@ -110,7 +110,7 @@ abstract class QuorumLockManager extends LockManager {
                foreach ( $pathsToUnlock as $bucket => $pathsToUnlockByType ) {
                        $status->merge( $this->doUnlockingRequestBucket( $bucket, $pathsToUnlockByType ) );
                }
-               if ( !count( $this->locksHeld ) ) {
+               if ( $this->locksHeld === [] ) {
                        $status->merge( $this->releaseAllLocks() );
                        $this->degradedBuckets = []; // safe to retry the normal quorum
                }
index a270105..993eea9 100644 (file)
@@ -364,6 +364,7 @@ class XmlTypeCheck {
                        $this->filterMatchType = $callbackReturn;
                }
        }
+
        /**
         * Handle coming across a <!DOCTYPE declaration.
         *
index 938e534..3e71e36 100644 (file)
@@ -202,7 +202,7 @@ class ChronologyProtector implements LoggerAwareInterface {
                        );
                }
 
-               if ( !count( $this->shutdownPositions ) ) {
+               if ( $this->shutdownPositions === [] ) {
                        return []; // nothing to save
                }
 
index 9a9e36a..7d971af 100644 (file)
@@ -2855,7 +2855,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        public function upsert( $table, array $rows, array $uniqueIndexes, array $set,
                $fname = __METHOD__
        ) {
-               if ( !count( $rows ) ) {
+               if ( $rows === [] ) {
                        return true; // nothing to do
                }
 
index 3fcbcf9..186c89f 100644 (file)
@@ -1337,7 +1337,7 @@ abstract class DatabaseMysqlBase extends Database {
        public function upsert( $table, array $rows, array $uniqueIndexes,
                array $set, $fname = __METHOD__
        ) {
-               if ( !count( $rows ) ) {
+               if ( $rows === [] ) {
                        return true; // nothing to do
                }
 
index ca18122..ab5c3cd 100644 (file)
@@ -408,7 +408,7 @@ class LoadBalancer implements ILoadBalancer {
         * @return array (reader index, lagged replica mode) or false on failure
         */
        private function pickReaderIndex( array $loads, $domain = false ) {
-               if ( !count( $loads ) ) {
+               if ( $loads === [] ) {
                        throw new InvalidArgumentException( "Empty server array given to LoadBalancer" );
                }
 
@@ -476,7 +476,7 @@ class LoadBalancer implements ILoadBalancer {
                }
 
                // If all servers were down, quit now
-               if ( !count( $currentLoads ) ) {
+               if ( $currentLoads === [] ) {
                        $this->connLogger->error( __METHOD__ . ": all servers down" );
                }
 
index 8a089f6..76a7760 100644 (file)
@@ -154,7 +154,7 @@ class EmailNotification {
                // If nobody is watching the page, and there are no users notified on all changes
                // don't bother creating a job/trying to send emails, unless it's a
                // talk page with an applicable notification.
-               if ( !count( $watchers ) && !count( $wgUsersNotifiedOnAllChanges ) ) {
+               if ( $watchers === [] && !count( $wgUsersNotifiedOnAllChanges ) ) {
                        $sendEmail = false;
                        // Only send notification for non minor edits, unless $wgEnotifMinorEdits
                        if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) {
index 8407992..a69e805 100644 (file)
@@ -733,6 +733,7 @@ class ParserOptions {
        public function getMagicPMIDLinks() {
                return $this->getOption( 'magicPMIDLinks' );
        }
+
        /**
         * Are magic RFC links enabled?
         * @since 1.28
index f4e4efa..3bcd012 100644 (file)
@@ -878,7 +878,7 @@ class PPDStack {
        }
 
        public function pop() {
-               if ( !count( $this->stack ) ) {
+               if ( $this->stack === [] ) {
                        throw new MWException( __METHOD__ . ': no elements remaining' );
                }
                $temp = array_pop( $this->stack );
@@ -902,7 +902,7 @@ class PPDStack {
         * @return array
         */
        public function getFlags() {
-               if ( !count( $this->stack ) ) {
+               if ( $this->stack === [] ) {
                        return [
                                'findEquals' => false,
                                'findPipe' => false,
index 9570e03..c513aed 100644 (file)
@@ -781,7 +781,7 @@ class ResourceLoader implements LoggerAwareInterface {
                }
 
                // Save response to file cache unless there are errors
-               if ( isset( $fileCache ) && !$this->errors && !count( $missing ) ) {
+               if ( isset( $fileCache ) && !$this->errors && $missing === [] ) {
                        // Cache single modules and images...and other requests if there are enough hits
                        if ( ResourceFileCache::useFileCache( $context ) ) {
                                if ( $fileCache->isCacheWorthy() ) {
@@ -1036,7 +1036,7 @@ class ResourceLoader implements LoggerAwareInterface {
                $out = '';
                $states = [];
 
-               if ( !count( $modules ) && !count( $missing ) ) {
+               if ( $modules === [] && $missing === [] ) {
                        return <<<MESSAGE
 /* This file is the Web entry point for MediaWiki's ResourceLoader:
    <https://www.mediawiki.org/wiki/ResourceLoader>. In this request,
index ef11628..b15efae 100644 (file)
@@ -295,9 +295,20 @@ class ResourceLoaderImage {
                $dom = new DOMDocument;
                $dom->loadXML( file_get_contents( $this->getPath( $context ) ) );
                $root = $dom->documentElement;
+               $titleNode = null;
                $wrapper = $dom->createElement( 'g' );
+               // Reattach all direct children of the `<svg>` root node to the `<g>` wrapper
                while ( $root->firstChild ) {
-                       $wrapper->appendChild( $root->firstChild );
+                       $node = $root->firstChild;
+                       if ( !$titleNode && $node->nodeType === XML_ELEMENT_NODE && $node->tagName === 'title' ) {
+                               // Remember the first encountered `<title>` node
+                               $titleNode = $node;
+                       }
+                       $wrapper->appendChild( $node );
+               }
+               if ( $titleNode ) {
+                       // Reattach the `<title>` node to the `<svg>` root node rather than the `<g>` wrapper
+                       $root->appendChild( $titleNode );
                }
                $root->appendChild( $wrapper );
                $wrapper->setAttribute( 'fill', $variantConf['color'] );
index 9cd245a..0cbb41c 100644 (file)
@@ -98,7 +98,7 @@ class SearchOracle extends SearchDatabase {
                if ( is_null( $this->namespaces ) ) {
                        return '';
                }
-               if ( !count( $this->namespaces ) ) {
+               if ( $this->namespaces === [] ) {
                        $namespaces = '0';
                } else {
                        $namespaces = $this->db->makeList( $this->namespaces );
index 6332ea2..f653796 100644 (file)
@@ -199,7 +199,7 @@ class SearchSqlite extends SearchDatabase {
                if ( is_null( $this->namespaces ) ) {
                        return '';  # search all
                }
-               if ( !count( $this->namespaces ) ) {
+               if ( $this->namespaces === [] ) {
                        $namespaces = '0';
                } else {
                        $namespaces = $this->db->makeList( $this->namespaces );
index 08ff8f0..e31bc06 100644 (file)
@@ -519,7 +519,7 @@ abstract class Skin extends ContextSource {
                $out = $this->getOutput();
                $allCats = $out->getCategoryLinks();
 
-               if ( !count( $allCats ) ) {
+               if ( $allCats === [] ) {
                        return '';
                }
 
index 47d61b8..e47ef06 100644 (file)
@@ -399,6 +399,10 @@ class SpecialBlock extends FormSpecialPage {
                                        $pageRestrictions[] = $restriction->getTitle()->getPrefixedText();
                                }
 
+                               if ( !$block->isSitewide() && empty( $pageRestrictions ) ) {
+                                       $fields['Editing']['default'] = false;
+                               }
+
                                // Sort the restrictions so they are in alphabetical order.
                                sort( $pageRestrictions );
                                $fields['PageRestrictions']['default'] = implode( "\n", $pageRestrictions );
@@ -1158,6 +1162,12 @@ class SpecialBlock extends FormSpecialPage {
         * @return bool|array True for success, false for didn't-try, array of errors on failure
         */
        public function onSubmit( array $data, HTMLForm $form = null ) {
+               // If "Editing" checkbox is unchecked, the block must be a partial block affecting
+               // actions other than editing, and there must be no restrictions.
+               if ( isset( $data['Editing'] ) && $data['Editing'] === false ) {
+                       $data['EditingRestriction'] = 'partial';
+                       $data['PageRestrictions'] = [];
+               }
                return self::processForm( $data, $form->getContext() );
        }
 
index 70b4207..b05c81a 100644 (file)
@@ -431,7 +431,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         * Attempts to clean up broken items
         */
        private function cleanupWatchlist() {
-               if ( !count( $this->badItems ) ) {
+               if ( $this->badItems === [] ) {
                        return; // nothing to do
                }
 
index 1a04eec..ba16baf 100644 (file)
@@ -62,7 +62,7 @@ class SpecialListGrants extends SpecialPage {
                                        '<span class="mw-listgrants-right-name">' . $permission . '</span>'
                                )->parse();
                        }
-                       if ( !count( $descs ) ) {
+                       if ( $descs === [] ) {
                                $grantCellHtml = '';
                        } else {
                                sort( $descs );
index 0a3a679..573dcb5 100644 (file)
@@ -151,7 +151,7 @@ class SpecialPasswordPolicies extends SpecialPage {
                                '<span class="mw-passwordpolicies-policy-name">' . $gp . '</span>'
                        )->parse();
                }
-               if ( !count( $ret ) ) {
+               if ( $ret === [] ) {
                        return '';
                } else {
                        return '<ul><li>' . implode( "</li>\n<li>", $ret ) . '</li></ul>';
index 60e797e..b566305 100644 (file)
@@ -709,7 +709,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
 
-               if ( !count( $categories ) ) {
+               if ( $categories === [] ) {
                        return;
                }
 
@@ -744,7 +744,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                }
 
                # Shortcut?
-               if ( !count( $articles ) || !count( $cats ) ) {
+               if ( $articles === [] || $cats === [] ) {
                        return;
                }
 
index d904ad1..ec6c5b9 100644 (file)
@@ -212,13 +212,13 @@ class SpecialSearch extends SpecialPage {
 
                # Extract manually requested namespaces
                $nslist = $this->powerSearch( $request );
-               if ( !count( $nslist ) ) {
+               if ( $nslist === [] ) {
                        # Fallback to user preference
                        $nslist = $this->searchConfig->userNamespaces( $user );
                }
 
                $profile = null;
-               if ( !count( $nslist ) ) {
+               if ( $nslist === [] ) {
                        $profile = 'default';
                }
 
index 585a7cd..9de31da 100644 (file)
@@ -55,7 +55,7 @@ class SpecialSpecialpages extends UnlistedSpecialPage {
                $pages = MediaWikiServices::getInstance()->getSpecialPageFactory()->
                        getUsablePages( $this->getUser() );
 
-               if ( !count( $pages ) ) {
+               if ( $pages === [] ) {
                        # Yeah, that was pointless. Thanks for coming.
                        return false;
                }
index 3ee7cea..4a586b7 100644 (file)
@@ -94,7 +94,7 @@ class SpecialTrackingCategories extends SpecialPage {
                        }
 
                        # Extra message, when no category was found
-                       if ( !count( $allMsgs ) ) {
+                       if ( $allMsgs === [] ) {
                                $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
                        }
 
index 65fc4b4..79889ae 100644 (file)
@@ -1579,7 +1579,7 @@ class User implements IDBAccessObject, UserIdentity {
 
                if ( is_array( $data ) ) {
                        if ( isset( $data['user_groups'] ) && is_array( $data['user_groups'] ) ) {
-                               if ( !count( $data['user_groups'] ) ) {
+                               if ( $data['user_groups'] === [] ) {
                                        $this->mGroupMemberships = [];
                                } else {
                                        $firstGroup = reset( $data['user_groups'] );
@@ -1645,7 +1645,7 @@ class User implements IDBAccessObject, UserIdentity {
                }
 
                $toPromote = Autopromote::getAutopromoteOnceGroups( $this, $event );
-               if ( !count( $toPromote ) ) {
+               if ( $toPromote === [] ) {
                        return [];
                }
 
index 853601e..c0efd24 100644 (file)
@@ -45,6 +45,7 @@ class InterwikiSearchResultSetWidget implements SearchResultSetWidget {
                $this->output = $specialSearch->getOutput();
                $this->showMultimedia = $showMultimedia;
        }
+
        /**
         * @param string $term User provided search term
         * @param SearchResultSet|SearchResultSet[] $resultSets List of interwiki
index 6ad7917..cedb19d 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
+    <title>remove</title>
     <g id="remove">
         <path id="trash-can" d="M12 10h-1v6h1v-6zm-2 0h-1v6h1v-6zm4 0h-1v6h1v-6zm0-4v-1h-5v1h-3v3h1v7.966l1 1.031v-.074.077h6.984l.016-.018v.015l1-1.031v-7.966h1v-3h-3zm1 11h-7v-8h7v8zm1-9h-9v-1h9v1z"/>
     </g>
index bcbe871..009d805 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
-<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="red">
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><default:title xmlns:default="http://www.w3.org/2000/svg">remove</default:title><g fill="red">
+    
     <g xmlns:default="http://www.w3.org/2000/svg" id="remove">
         <path id="trash-can" d="M12 10h-1v6h1v-6zm-2 0h-1v6h1v-6zm4 0h-1v6h1v-6zm0-4v-1h-5v1h-3v3h1v7.966l1 1.031v-.074.077h6.984l.016-.018v.015l1-1.031v-7.966h1v-3h-3zm1 11h-7v-8h7v8zm1-9h-9v-1h9v1z"/>
     </g>
index cf5e808..68632f3 100644 (file)
@@ -102,6 +102,7 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase {
                $this->testPageTitle = Title::newFromText( 'UTPage-' . __CLASS__ );
                return $this->testPageTitle;
        }
+
        /**
         * @return WikiPage
         */
index a0a99cc..ac0ad98 100644 (file)
@@ -9,10 +9,12 @@ class WebPHandlerTest extends MediaWikiTestCase {
                // Allocated file for testing
                $this->tempFileName = tempnam( wfTempDir(), 'WEBP' );
        }
+
        public function tearDown() {
                parent::tearDown();
                unlink( $this->tempFileName );
        }
+
        /**
         * @dataProvider provideTestExtractMetaData
         */
@@ -22,6 +24,7 @@ class WebPHandlerTest extends MediaWikiTestCase {
 
                $this->assertEquals( $expectedResult, WebPHandler::extractMetadata( $this->tempFileName ) );
        }
+
        public function provideTestExtractMetaData() {
                // phpcs:disable Generic.Files.LineLength
                return [
@@ -80,6 +83,7 @@ class WebPHandlerTest extends MediaWikiTestCase {
        public function testWithFileExtractMetaData( $filename, $expectedResult ) {
                $this->assertEquals( $expectedResult, WebPHandler::extractMetadata( $filename ) );
        }
+
        public function provideTestWithFileExtractMetaData() {
                return [
                        [ __DIR__ . '/../../data/media/2_webp_ll.webp',
@@ -108,6 +112,7 @@ class WebPHandlerTest extends MediaWikiTestCase {
                $handler = new WebPHandler();
                $this->assertEquals( $expectedResult, $handler->getImageSize( null, $path ) );
        }
+
        public function provideTestGetImageSize() {
                return [
                        // Public domain files from https://developers.google.com/speed/webp/gallery2
@@ -130,6 +135,7 @@ class WebPHandlerTest extends MediaWikiTestCase {
                $mime = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
                $this->assertEquals( 'image/webp', $mime->guessMimeType( $path, false ) );
        }
+
        public function provideTestGetMimeType() {
                return [
                                // Public domain files from https://developers.google.com/speed/webp/gallery2
index 19774f0..016a9a0 100644 (file)
@@ -118,6 +118,7 @@ class PoolWorkArticleViewTest extends MediaWikiTestCase {
                        }
                ];
        }
+
        /**
         * @dataProvider provideMagicWords
         */
index bb51de0..318dce8 100644 (file)
@@ -31,6 +31,7 @@ class ResourceLoaderLessVarFileModuleTest extends ResourceLoaderTestCase {
                        ]
                ];
        }
+
        /**
         * @dataProvider providerWrapAndEscapeMessage
         * @covers ResourceLoaderLessVarFileModule::wrapAndEscapeMessage
index aa3f820..2ee85b5 100644 (file)
@@ -499,6 +499,7 @@ mw.loader.register( [
                        ] ]
                ];
        }
+
        /**
         * @covers ResourceLoaderStartUpModule::getModuleRegistrations
         * @dataProvider provideRegistrations
index 171f2a6..32afd75 100644 (file)
@@ -837,6 +837,7 @@ mw.example();
                        $response
                );
        }
+
        /**
         * Verify that when building the startup module response,
         * an exception from one module class will not break the entire
index e796065..26088a3 100644 (file)
@@ -84,6 +84,7 @@ class UploadStashTest extends MediaWikiTestCase {
                                ] ) ],
                ];
        }
+
        /**
         * @dataProvider provideValidRequests
         */