Merge "Consistently follow conventions for documenting parameters"
[lhc/web/wiklou.git] / includes / LinksUpdate.php
index f54487a..0b7393a 100644 (file)
@@ -27,7 +27,7 @@
  */
 class LinksUpdate extends SqlDataUpdate {
 
-       // @todo: make members protected, but make sure extensions don't break
+       // @todo make members protected, but make sure extensions don't break
 
        public $mId,         //!< Page ID of the article linked from
                $mTitle,         //!< Title object of the article linked from
@@ -237,22 +237,36 @@ class LinksUpdate extends SqlDataUpdate {
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * Queue recursive jobs for this page
+        *
+        * Which means do LinksUpdate on all templates
+        * that include the current page, using the job queue.
+        */
        function queueRecursiveJobs() {
-               wfProfileIn( __METHOD__ );
+               self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
+       }
 
-               if ( $this->mTitle->getBacklinkCache()->hasLinks( 'templatelinks' ) ) {
+       /**
+        * Queue a RefreshLinks job for any table.
+        *
+        * @param Title $title Title to do job for
+        * @param String $table Table to use (e.g. 'templatelinks')
+        */
+       public static function queueRecursiveJobsForTable( Title $title, $table ) {
+               wfProfileIn( __METHOD__ );
+               if ( $title->getBacklinkCache()->hasLinks( $table ) ) {
                        $job = new RefreshLinksJob2(
-                               $this->mTitle,
+                               $title,
                                array(
-                                       'table' => 'templatelinks',
+                                       'table' => $table,
                                ) + Job::newRootJobParams( // "overall" refresh links job info
-                                       "refreshlinks:templatelinks:{$this->mTitle->getPrefixedText()}"
+                                       "refreshlinks:{$table}:{$title->getPrefixedText()}"
                                )
                        );
                        JobQueueGroup::singleton()->push( $job );
                        JobQueueGroup::singleton()->deduplicateRootJob( $job );
                }
-
                wfProfileOut( __METHOD__ );
        }
 
@@ -354,7 +368,7 @@ class LinksUpdate extends SqlDataUpdate {
         */
        private function getLinkInsertions( $existing = array() ) {
                $arr = array();
-               foreach( $this->mLinks as $ns => $dbkeys ) {
+               foreach ( $this->mLinks as $ns => $dbkeys ) {
                        $diffs = isset( $existing[$ns] )
                                ? array_diff_key( $dbkeys, $existing[$ns] )
                                : $dbkeys;
@@ -376,7 +390,7 @@ class LinksUpdate extends SqlDataUpdate {
         */
        private function getTemplateInsertions( $existing = array() ) {
                $arr = array();
-               foreach( $this->mTemplates as $ns => $dbkeys ) {
+               foreach ( $this->mTemplates as $ns => $dbkeys ) {
                        $diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
                        foreach ( $diffs as $dbk => $id ) {
                                $arr[] = array(
@@ -398,7 +412,7 @@ class LinksUpdate extends SqlDataUpdate {
        private function getImageInsertions( $existing = array() ) {
                $arr = array();
                $diffs = array_diff_key( $this->mImages, $existing );
-               foreach( $diffs as $iname => $dummy ) {
+               foreach ( $diffs as $iname => $dummy ) {
                        $arr[] = array(
                                'il_from' => $this->mId,
                                'il_to' => $iname
@@ -415,8 +429,8 @@ class LinksUpdate extends SqlDataUpdate {
        private function getExternalInsertions( $existing = array() ) {
                $arr = array();
                $diffs = array_diff_key( $this->mExternals, $existing );
-               foreach( $diffs as $url => $dummy ) {
-                       foreach( wfMakeUrlIndexes( $url ) as $index ) {
+               foreach ( $diffs as $url => $dummy ) {
+                       foreach ( wfMakeUrlIndexes( $url ) as $index ) {
                                $arr[] = array(
                                        'el_from' => $this->mId,
                                        'el_to' => $url,
@@ -481,7 +495,7 @@ class LinksUpdate extends SqlDataUpdate {
        private function getInterlangInsertions( $existing = array() ) {
                $diffs = array_diff_assoc( $this->mInterlangs, $existing );
                $arr = array();
-               foreach( $diffs as $lang => $title ) {
+               foreach ( $diffs as $lang => $title ) {
                        $arr[] = array(
                                'll_from' => $this->mId,
                                'll_lang' => $lang,
@@ -517,7 +531,7 @@ class LinksUpdate extends SqlDataUpdate {
         */
        private function getInterwikiInsertions( $existing = array() ) {
                $arr = array();
-               foreach( $this->mInterwikis as $prefix => $dbkeys ) {
+               foreach ( $this->mInterwikis as $prefix => $dbkeys ) {
                        $diffs = isset( $existing[$prefix] ) ? array_diff_key( $dbkeys, $existing[$prefix] ) : $dbkeys;
                        foreach ( $diffs as $dbk => $id ) {
                                $arr[] = array(