aboutsummaryrefslogtreecommitdiffstats
path: root/includes/deferred/LinksUpdate
diff options
context:
space:
mode:
authorBartosz Dziewo?ski <matma.rex@gmail.com>2023-09-26 02:36:51 +0200
committerBartosz DziewoƄski <matma.rex@gmail.com>2023-09-26 04:31:33 +0200
commit220f23d5f0a659bdbba7b41207ddf6c4e7e6b56d (patch)
treebdbb33de3ed3eff865d1a125251d7355a81a4b19 /includes/deferred/LinksUpdate
parent4031b0a0d856db3ee71b995a5f9afe81e6f44914 (diff)
downloadmediawikicore-220f23d5f0a659bdbba7b41207ddf6c4e7e6b56d.tar.gz
mediawikicore-220f23d5f0a659bdbba7b41207ddf6c4e7e6b56d.zip
DerivedPageDataUpdater: Only do RefreshLinks on file page redirect changes
Previously, we scheduled recursive RefreshLinks jobs on every file page edit, but it's only necessary when the page's redirect target has changed. Optimize this, and only schedule them when the page is or was a redirect. (We still do it unnecessarily when a redirect page is edited without changing the target, but that's more difficult to detect at this point.) Bug: T346383 Change-Id: Ie629881c94a7a81ae7bf597aab4587921d1c25ae
Diffstat (limited to 'includes/deferred/LinksUpdate')
-rw-r--r--includes/deferred/LinksUpdate/LinksUpdate.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/includes/deferred/LinksUpdate/LinksUpdate.php b/includes/deferred/LinksUpdate/LinksUpdate.php
index 7edc050bec3f..d5789d6a7e9e 100644
--- a/includes/deferred/LinksUpdate/LinksUpdate.php
+++ b/includes/deferred/LinksUpdate/LinksUpdate.php
@@ -66,6 +66,9 @@ class LinksUpdate extends DataUpdate {
/** @var bool Whether to queue jobs for recursive updates */
protected $mRecursive;
+ /** @var bool Whether the page's redirect target may have changed in the latest revision */
+ protected $mMaybeRedirectChanged;
+
/** @var RevisionRecord Revision for which this update has been triggered */
private $mRevisionRecord;
@@ -84,15 +87,23 @@ class LinksUpdate extends DataUpdate {
* @param PageIdentity $page The page we're updating
* @param ParserOutput $parserOutput Output from a full parse of this page
* @param bool $recursive Queue jobs for recursive updates?
+ * @param bool $maybeRedirectChanged True if the page's redirect target may have changed in the
+ * latest revision. If false, this is used as a hint to skip some unnecessary updates.
*
* @throws MWException
*/
- public function __construct( PageIdentity $page, ParserOutput $parserOutput, $recursive = true ) {
+ public function __construct(
+ PageIdentity $page,
+ ParserOutput $parserOutput,
+ $recursive = true,
+ $maybeRedirectChanged = true
+ ) {
parent::__construct();
$this->mTitle = Title::newFromPageIdentity( $page );
$this->mParserOutput = $parserOutput;
$this->mRecursive = $recursive;
+ $this->mMaybeRedirectChanged = $maybeRedirectChanged;
$services = MediaWikiServices::getInstance();
$config = $services->getMainConfig();
@@ -238,8 +249,8 @@ class LinksUpdate extends DataUpdate {
self::queueRecursiveJobsForTable(
$this->mTitle, 'templatelinks', $action, $agent, $backlinkCache
);
- if ( $this->mTitle->getNamespace() === NS_FILE ) {
- // Process imagelinks in case the title is or was a redirect
+ if ( $this->mMaybeRedirectChanged && $this->mTitle->getNamespace() === NS_FILE ) {
+ // Process imagelinks in case the redirect target has changed
self::queueRecursiveJobsForTable(
$this->mTitle, 'imagelinks', $action, $agent, $backlinkCache
);