New hook: OpportunisticLinksUpdate
authordaniel <daniel.kinzler@wikimedia.de>
Wed, 18 Mar 2015 17:21:25 +0000 (18:21 +0100)
committerDaniel Kinzler <daniel.kinzler@wikimedia.de>
Wed, 1 Apr 2015 11:17:57 +0000 (11:17 +0000)
Change-Id: I8b9238cd6b0010ad91fae24d4eb1e7cd0c201931

RELEASE-NOTES-1.25
docs/hooks.txt
includes/page/WikiPage.php

index 0bf7a80..a31461c 100644 (file)
@@ -408,6 +408,8 @@ changes to languages because of Bugzilla reports.
   addSecondaryDataUpdate throwing an exception. These functions will be removed in 1.26,
   since they interfere with caching of ParserOutput objects.
 * Introduced new hook 'SecondaryDataUpdates' that allows extensions to inject custom updates.
+* Introduced new hook 'OpportunisticLinksUpdate' that allows extensions to perform
+  updates when a page is re-rendered.
 * EditPage::attemptSave has been modified not to call handleStatus itself and
   instead just returns the Status object. Extension calling it should be aware of
   this.
index f2c47ca..877b7ed 100644 (file)
@@ -2012,6 +2012,17 @@ return false to omit the line from RecentChanges and Watchlist special pages.
 can alter or append to the array of URLs for search & suggestion formats.
 &$urls: array of associative arrays with Url element attributes
 
+'OpportunisticLinksUpdate': Called by WikiPage::triggerOpportunisticLinksUpdate
+when a page view triggers a re-rendering of the page. This may happen
+particularly if the parser cache is split by user language, and no cached
+rendering of the page exists in the user's language. The hook is called
+before checking whether page_links_updated indicates that the links are up
+to date. Returning false will cause triggerOpportunisticLinksUpdate() to abort
+without triggering any updates.
+$page: the Page that was rendered.
+$title: the Title of the rendered page.
+$parserOutput: ParserOutput resulting from rendering the page.
+
 'OtherBlockLogLink': Get links to the block log from extensions which blocks
 users and/or IP addresses too.
 $otherBlockLink: An array with links to other block logs
index 0452c41..d96e271 100644 (file)
@@ -3394,12 +3394,15 @@ class WikiPage implements Page, IDBAccessObject {
         * Opportunistically enqueue link update jobs given fresh parser output if useful
         *
         * @param ParserOutput $parserOutput Current version page output
-        * @return bool Whether a job was pushed
         * @since 1.25
         */
        public function triggerOpportunisticLinksUpdate( ParserOutput $parserOutput ) {
                if ( wfReadOnly() ) {
-                       return false;
+                       return;
+               }
+
+               if ( !Hooks::run( 'OpportunisticLinksUpdate', array( $this, $this->mTitle, $parserOutput ) ) ) {
+                       return;
                }
 
                if ( $this->mTitle->areRestrictionsCascading() ) {
@@ -3410,7 +3413,7 @@ class WikiPage implements Page, IDBAccessObject {
                        $params = array();
                } else {
                        // If the inclusions are deterministic, the edit-triggered link jobs are enough
-                       return false;
+                       return;
                }
 
                // Check if the last link refresh was before page_touched
@@ -3418,10 +3421,10 @@ class WikiPage implements Page, IDBAccessObject {
                        JobQueueGroup::singleton()->push( EnqueueJob::newFromLocalJobs(
                                new JobSpecification( 'refreshLinks', $params, array(), $this->mTitle )
                        ) );
-                       return true;
+                       return;
                }
 
-               return false;
+               return;
        }
 
        /**