Convert all array() syntax to []
[lhc/web/wiklou.git] / includes / deferred / LinksUpdate.php
index 755a7cd..4215ed0 100644 (file)
@@ -91,7 +91,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                parent::__construct( false ); // no implicit transaction
 
                $this->mTitle = $title;
-               $this->mId = $title->getArticleID();
+               $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
 
                if ( !$this->mId ) {
                        throw new InvalidArgumentException(
@@ -114,7 +114,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                # the way back to the skin, so either a skin API break would be required, or an
                # inefficient back-conversion.
                $ill = $parserOutput->getLanguageLinks();
-               $this->mInterlangs = array();
+               $this->mInterlangs = [];
                foreach ( $ill as $link ) {
                        list( $key, $title ) = explode( ':', $link, 2 );
                        $this->mInterlangs[$key] = $title;
@@ -133,19 +133,18 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
 
                $this->mRecursive = $recursive;
 
-               Hooks::run( 'LinksUpdateConstructed', array( &$this ) );
+               Hooks::run( 'LinksUpdateConstructed', [ &$this ] );
        }
 
        /**
         * Update link tables with outgoing links from an updated article
         */
        public function doUpdate() {
-               Hooks::run( 'LinksUpdate', array( &$this ) );
+               Hooks::run( 'LinksUpdate', [ &$this ] );
                $this->doIncrementalUpdate();
 
-               $that = $this;
-               $this->mDb->onTransactionIdle( function() use ( $that ) {
-                       Hooks::run( 'LinksUpdateComplete', array( &$that ) );
+               $this->mDb->onTransactionIdle( function() {
+                       Hooks::run( 'LinksUpdateComplete', [ &$this ] );
                } );
        }
 
@@ -243,9 +242,9 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                // should be implicitly protected as soon as possible, if applicable.
                // These jobs duplicate a subset of the above ones, but can run sooner.
                // Which ever runs first generally no-ops the other one.
-               $jobs = array();
+               $jobs = [];
                foreach ( $bc->getCascadeProtectedLinks() as $title ) {
-                       $jobs[] = RefreshLinksJob::newPrioritized( $title, array() );
+                       $jobs[] = RefreshLinksJob::newPrioritized( $title, [] );
                }
                JobQueueGroup::singleton()->push( $jobs );
        }
@@ -260,10 +259,10 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                if ( $title->getBacklinkCache()->hasLinks( $table ) ) {
                        $job = new RefreshLinksJob(
                                $title,
-                               array(
+                               [
                                        'table' => $table,
                                        'recursive' => true,
-                               ) + Job::newRootJobParams( // "overall" refresh links job info
+                               ] + Job::newRootJobParams( // "overall" refresh links job info
                                        "refreshlinks:{$table}:{$title->getPrefixedText()}"
                                )
                        );
@@ -311,7 +310,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                } else {
                        $fromField = "{$prefix}_from";
                }
-               $where = array( $fromField => $this->mId );
+               $where = [ $fromField => $this->mId ];
                if ( $table == 'pagelinks' || $table == 'templatelinks' || $table == 'iwlinks' ) {
                        if ( $table == 'iwlinks' ) {
                                $baseKey = 'iwl_prefix';
@@ -343,7 +342,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                }
                if ( count( $insertions ) ) {
                        $this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' );
-                       Hooks::run( 'LinksUpdateAfterInsert', array( $this, $table, $insertions ) );
+                       Hooks::run( 'LinksUpdateAfterInsert', [ $this, $table, $insertions ] );
                }
        }
 
@@ -353,19 +352,19 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @param array $existing
         * @return array
         */
-       private function getLinkInsertions( $existing = array() ) {
-               $arr = array();
+       private function getLinkInsertions( $existing = [] ) {
+               $arr = [];
                foreach ( $this->mLinks as $ns => $dbkeys ) {
                        $diffs = isset( $existing[$ns] )
                                ? array_diff_key( $dbkeys, $existing[$ns] )
                                : $dbkeys;
                        foreach ( $diffs as $dbk => $id ) {
-                               $arr[] = array(
+                               $arr[] = [
                                        'pl_from' => $this->mId,
                                        'pl_from_namespace' => $this->mTitle->getNamespace(),
                                        'pl_namespace' => $ns,
                                        'pl_title' => $dbk
-                               );
+                               ];
                        }
                }
 
@@ -377,17 +376,17 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @param array $existing
         * @return array
         */
-       private function getTemplateInsertions( $existing = array() ) {
-               $arr = array();
+       private function getTemplateInsertions( $existing = [] ) {
+               $arr = [];
                foreach ( $this->mTemplates as $ns => $dbkeys ) {
                        $diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
                        foreach ( $diffs as $dbk => $id ) {
-                               $arr[] = array(
+                               $arr[] = [
                                        'tl_from' => $this->mId,
                                        'tl_from_namespace' => $this->mTitle->getNamespace(),
                                        'tl_namespace' => $ns,
                                        'tl_title' => $dbk
-                               );
+                               ];
                        }
                }
 
@@ -400,15 +399,15 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @param array $existing
         * @return array
         */
-       private function getImageInsertions( $existing = array() ) {
-               $arr = array();
+       private function getImageInsertions( $existing = [] ) {
+               $arr = [];
                $diffs = array_diff_key( $this->mImages, $existing );
                foreach ( $diffs as $iname => $dummy ) {
-                       $arr[] = array(
+                       $arr[] = [
                                'il_from' => $this->mId,
                                'il_from_namespace' => $this->mTitle->getNamespace(),
                                'il_to' => $iname
-                       );
+                       ];
                }
 
                return $arr;
@@ -419,17 +418,17 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @param array $existing
         * @return array
         */
-       private function getExternalInsertions( $existing = array() ) {
-               $arr = array();
+       private function getExternalInsertions( $existing = [] ) {
+               $arr = [];
                $diffs = array_diff_key( $this->mExternals, $existing );
                foreach ( $diffs as $url => $dummy ) {
                        foreach ( wfMakeUrlIndexes( $url ) as $index ) {
-                               $arr[] = array(
+                               $arr[] = [
                                        'el_id' => $this->mDb->nextSequenceValue( 'externallinks_el_id_seq' ),
                                        'el_from' => $this->mId,
                                        'el_to' => $url,
                                        'el_index' => $index,
-                               );
+                               ];
                        }
                }
 
@@ -444,10 +443,10 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         *
         * @return array
         */
-       private function getCategoryInsertions( $existing = array() ) {
+       private function getCategoryInsertions( $existing = [] ) {
                global $wgContLang, $wgCategoryCollation;
                $diffs = array_diff_assoc( $this->mCategories, $existing );
-               $arr = array();
+               $arr = [];
                foreach ( $diffs as $name => $prefix ) {
                        $nt = Title::makeTitleSafe( NS_CATEGORY, $name );
                        $wgContLang->findVariantLink( $name, $nt, true );
@@ -467,7 +466,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                        $sortkey = Collation::singleton()->getSortKey(
                                $this->mTitle->getCategorySortkey( $prefix ) );
 
-                       $arr[] = array(
+                       $arr[] = [
                                'cl_from' => $this->mId,
                                'cl_to' => $name,
                                'cl_sortkey' => $sortkey,
@@ -475,7 +474,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                                'cl_sortkey_prefix' => $prefix,
                                'cl_collation' => $wgCategoryCollation,
                                'cl_type' => $type,
-                       );
+                       ];
                }
 
                return $arr;
@@ -488,15 +487,15 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         *
         * @return array
         */
-       private function getInterlangInsertions( $existing = array() ) {
+       private function getInterlangInsertions( $existing = [] ) {
                $diffs = array_diff_assoc( $this->mInterlangs, $existing );
-               $arr = array();
+               $arr = [];
                foreach ( $diffs as $lang => $title ) {
-                       $arr[] = array(
+                       $arr[] = [
                                'll_from' => $this->mId,
                                'll_lang' => $lang,
                                'll_title' => $title
-                       );
+                       ];
                }
 
                return $arr;
@@ -507,10 +506,10 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @param array $existing
         * @return array
         */
-       function getPropertyInsertions( $existing = array() ) {
+       function getPropertyInsertions( $existing = [] ) {
                $diffs = array_diff_assoc( $this->mProperties, $existing );
 
-               $arr = array();
+               $arr = [];
                foreach ( array_keys( $diffs ) as $name ) {
                        $arr[] = $this->getPagePropRowData( $name );
                }
@@ -539,11 +538,11 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
 
                $value = $this->mProperties[$prop];
 
-               $row = array(
+               $row = [
                        'pp_page' => $this->mId,
                        'pp_propname' => $prop,
                        'pp_value' => $value,
-               );
+               ];
 
                if ( $wgPagePropsHaveSortkey ) {
                        $row['pp_sortkey'] = $this->getPropertySortKeyValue( $value );
@@ -578,19 +577,19 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @param array $existing
         * @return array
         */
-       private function getInterwikiInsertions( $existing = array() ) {
-               $arr = array();
+       private function getInterwikiInsertions( $existing = [] ) {
+               $arr = [];
                foreach ( $this->mInterwikis as $prefix => $dbkeys ) {
                        $diffs = isset( $existing[$prefix] )
                                ? array_diff_key( $dbkeys, $existing[$prefix] )
                                : $dbkeys;
 
                        foreach ( $diffs as $dbk => $id ) {
-                               $arr[] = array(
+                               $arr[] = [
                                        'iwl_from' => $this->mId,
                                        'iwl_prefix' => $prefix,
                                        'iwl_title' => $dbk
-                               );
+                               ];
                        }
                }
 
@@ -604,7 +603,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getLinkDeletions( $existing ) {
-               $del = array();
+               $del = [];
                foreach ( $existing as $ns => $dbkeys ) {
                        if ( isset( $this->mLinks[$ns] ) ) {
                                $del[$ns] = array_diff_key( $existing[$ns], $this->mLinks[$ns] );
@@ -623,7 +622,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getTemplateDeletions( $existing ) {
-               $del = array();
+               $del = [];
                foreach ( $existing as $ns => $dbkeys ) {
                        if ( isset( $this->mTemplates[$ns] ) ) {
                                $del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates[$ns] );
@@ -691,7 +690,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getInterwikiDeletions( $existing ) {
-               $del = array();
+               $del = [];
                foreach ( $existing as $prefix => $dbkeys ) {
                        if ( isset( $this->mInterwikis[$prefix] ) ) {
                                $del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis[$prefix] );
@@ -709,12 +708,12 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getExistingLinks() {
-               $res = $this->mDb->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
-                       array( 'pl_from' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'pagelinks', [ 'pl_namespace', 'pl_title' ],
+                       [ 'pl_from' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        if ( !isset( $arr[$row->pl_namespace] ) ) {
-                               $arr[$row->pl_namespace] = array();
+                               $arr[$row->pl_namespace] = [];
                        }
                        $arr[$row->pl_namespace][$row->pl_title] = 1;
                }
@@ -728,12 +727,12 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getExistingTemplates() {
-               $res = $this->mDb->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
-                       array( 'tl_from' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'templatelinks', [ 'tl_namespace', 'tl_title' ],
+                       [ 'tl_from' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        if ( !isset( $arr[$row->tl_namespace] ) ) {
-                               $arr[$row->tl_namespace] = array();
+                               $arr[$row->tl_namespace] = [];
                        }
                        $arr[$row->tl_namespace][$row->tl_title] = 1;
                }
@@ -747,9 +746,9 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getExistingImages() {
-               $res = $this->mDb->select( 'imagelinks', array( 'il_to' ),
-                       array( 'il_from' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'imagelinks', [ 'il_to' ],
+                       [ 'il_from' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        $arr[$row->il_to] = 1;
                }
@@ -763,9 +762,9 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getExistingExternals() {
-               $res = $this->mDb->select( 'externallinks', array( 'el_to' ),
-                       array( 'el_from' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'externallinks', [ 'el_to' ],
+                       [ 'el_from' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        $arr[$row->el_to] = 1;
                }
@@ -779,9 +778,9 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getExistingCategories() {
-               $res = $this->mDb->select( 'categorylinks', array( 'cl_to', 'cl_sortkey_prefix' ),
-                       array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'categorylinks', [ 'cl_to', 'cl_sortkey_prefix' ],
+                       [ 'cl_from' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        $arr[$row->cl_to] = $row->cl_sortkey_prefix;
                }
@@ -796,9 +795,9 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getExistingInterlangs() {
-               $res = $this->mDb->select( 'langlinks', array( 'll_lang', 'll_title' ),
-                       array( 'll_from' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'langlinks', [ 'll_lang', 'll_title' ],
+                       [ 'll_from' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        $arr[$row->ll_lang] = $row->ll_title;
                }
@@ -811,12 +810,12 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array (prefix => array(dbkey => 1))
         */
        protected function getExistingInterwikis() {
-               $res = $this->mDb->select( 'iwlinks', array( 'iwl_prefix', 'iwl_title' ),
-                       array( 'iwl_from' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'iwlinks', [ 'iwl_prefix', 'iwl_title' ],
+                       [ 'iwl_from' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        if ( !isset( $arr[$row->iwl_prefix] ) ) {
-                               $arr[$row->iwl_prefix] = array();
+                               $arr[$row->iwl_prefix] = [];
                        }
                        $arr[$row->iwl_prefix][$row->iwl_title] = 1;
                }
@@ -830,9 +829,9 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
         * @return array Array of property names and values
         */
        private function getExistingProperties() {
-               $res = $this->mDb->select( 'page_props', array( 'pp_propname', 'pp_value' ),
-                       array( 'pp_page' => $this->mId ), __METHOD__, $this->mOptions );
-               $arr = array();
+               $res = $this->mDb->select( 'page_props', [ 'pp_propname', 'pp_value' ],
+                       [ 'pp_page' => $this->mId ], __METHOD__, $this->mOptions );
+               $arr = [];
                foreach ( $res as $row ) {
                        $arr[$row->pp_propname] = $row->pp_value;
                }
@@ -905,7 +904,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                        if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
                                $inv = $wgPagePropLinkInvalidations[$name];
                                if ( !is_array( $inv ) ) {
-                                       $inv = array( $inv );
+                                       $inv = [ $inv ];
                                }
                                foreach ( $inv as $table ) {
                                        DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) );
@@ -923,7 +922,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                if ( $this->linkInsertions === null ) {
                        return null;
                }
-               $result = array();
+               $result = [];
                foreach ( $this->linkInsertions as $insertion ) {
                        $result[] = Title::makeTitle( $insertion['pl_namespace'], $insertion['pl_title'] );
                }
@@ -940,7 +939,7 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                if ( $this->linkDeletions === null ) {
                        return null;
                }
-               $result = array();
+               $result = [];
                foreach ( $this->linkDeletions as $ns => $titles ) {
                        foreach ( $titles as $title => $unused ) {
                                $result[] = Title::makeTitle( $ns, $title );
@@ -958,8 +957,8 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                        // The link updates made here only reflect the freshness of the parser output
                        $timestamp = $this->mParserOutput->getCacheTime();
                        $this->mDb->update( 'page',
-                               array( 'page_links_updated' => $this->mDb->timestamp( $timestamp ) ),
-                               array( 'page_id' => $this->mId ),
+                               [ 'page_links_updated' => $this->mDb->timestamp( $timestamp ) ],
+                               [ 'page_id' => $this->mId ],
                                __METHOD__
                        );
                }
@@ -967,10 +966,10 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
 
        public function getAsJobSpecification() {
                if ( $this->user ) {
-                       $userInfo = array(
+                       $userInfo = [
                                'userId' => $this->user->getId(),
                                'userName' => $this->user->getName(),
-                       );
+                       ];
                } else {
                        $userInfo = false;
                }
@@ -981,20 +980,20 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
                        $triggeringRevisionId = false;
                }
 
-               return array(
+               return [
                        'wiki' => $this->mDb->getWikiID(),
                        'job'  => new JobSpecification(
                                'refreshLinksPrioritized',
-                               array(
+                               [
                                        // Reuse the parser cache if it was saved
                                        'rootJobTimestamp' => $this->mParserOutput->getCacheTime(),
                                        'useRecursiveLinksUpdate' => $this->mRecursive,
                                        'triggeringUser' => $userInfo,
                                        'triggeringRevisionId' => $triggeringRevisionId,
-                               ),
-                               array( 'removeDuplicates' => true ),
+                               ],
+                               [ 'removeDuplicates' => true ],
                                $this->getTitle()
                        )
-               );
+               ];
        }
 }