jenkins-bot has submitted this change and it was merged.

Change subject: New hook: OpportunisticLinksUpdate
......................................................................


New hook: OpportunisticLinksUpdate

Change-Id: I8b9238cd6b0010ad91fae24d4eb1e7cd0c201931
---
M RELEASE-NOTES-1.25
M docs/hooks.txt
M includes/page/WikiPage.php
3 files changed, 21 insertions(+), 5 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  Aaron Schulz: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index 0bf7a80..a31461c 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -408,6 +408,8 @@
   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.
diff --git a/docs/hooks.txt b/docs/hooks.txt
index f2c47ca..877b7ed 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -2012,6 +2012,17 @@
 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
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 0452c41..d96e271 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -3394,12 +3394,15 @@
         * 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 @@
                        $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 @@
                        JobQueueGroup::singleton()->push( 
EnqueueJob::newFromLocalJobs(
                                new JobSpecification( 'refreshLinks', $params, 
array(), $this->mTitle )
                        ) );
-                       return true;
+                       return;
                }
 
-               return false;
+               return;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/197663
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8b9238cd6b0010ad91fae24d4eb1e7cd0c201931
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Manybubbles <never...@wikimedia.org>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to