Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/197663
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/63/197663/1
diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index d1745d2..472e77a 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -400,6 +400,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 62285df..7384c99 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1994,6 +1994,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.
+$output: 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 b1e4f2d..492384e 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -3381,12 +3381,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() ) {
@@ -3397,7 +3400,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
@@ -3405,10 +3408,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: newchange
Gerrit-Change-Id: I8b9238cd6b0010ad91fae24d4eb1e7cd0c201931
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits