Merge "(bug 47070) check content model namespace on import."
[lhc/web/wiklou.git] / includes / deferred / LinksUpdate.php
index 9cd7708..8c3b671 100644 (file)
@@ -218,6 +218,9 @@ class LinksUpdate extends SqlDataUpdate {
                $changed = $propertiesDeletes + array_diff_assoc( $this->mProperties, $existing );
                $this->invalidateProperties( $changed );
 
+               # Update the links table freshness for this title
+               $this->updateLinksTimestamp();
+
                # Refresh links of all pages including this page
                # This will be in a separate transaction
                if ( $this->mRecursive ) {
@@ -230,11 +233,15 @@ class LinksUpdate extends SqlDataUpdate {
        /**
         * Queue recursive jobs for this page
         *
-        * Which means do LinksUpdate on all templates
-        * that include the current page, using the job queue.
+        * Which means do LinksUpdate on all pages that include the current page,
+        * using the job queue.
         */
        function queueRecursiveJobs() {
                self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
+               if ( $this->mTitle->getNamespace() == NS_FILE ) {
+                       // Process imagelinks in case the title is or was a redirect
+                       self::queueRecursiveJobsForTable( $this->mTitle, 'imagelinks' );
+               }
        }
 
        /**
@@ -411,6 +418,7 @@ class LinksUpdate extends SqlDataUpdate {
                foreach ( $diffs as $url => $dummy ) {
                        foreach ( wfMakeUrlIndexes( $url ) as $index ) {
                                $arr[] = array(
+                                       'el_id' => $this->mDb->nextSequenceValue( 'externallinks_el_id_seq' ),
                                        'el_from' => $this->mId,
                                        'el_to' => $url,
                                        'el_index' => $index,
@@ -855,6 +863,19 @@ class LinksUpdate extends SqlDataUpdate {
 
                return $result;
        }
+
+       /**
+        * Update links table freshness
+        */
+       protected function updateLinksTimestamp() {
+               if ( $this->mId ) {
+                       $this->mDb->update( 'page',
+                               array( 'page_links_updated' => $this->mDb->timestamp() ),
+                               array( 'page_id' => $this->mId ),
+                               __METHOD__
+                       );
+               }
+       }
 }
 
 /**