From 65eb2098e15dd0bdd64f1f18eb46943be3a9e592 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 16 Feb 2009 08:11:39 +0000 Subject: [PATCH] Fix the cascade protection templatelinks update routine, which apparently has been broken since it was introduced, causing it to flood the job queue with refreshLinks job on every parser cache miss: * Fixed incorrect interpretation of the result of $parserOutput->getTemplates() which led to the array_diff() always being non-empty * No need to check for $db->select()===false, it throws an exception in that case * Do a non-recursive update, no need to update links for other pages on a page view --- includes/Article.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 71e230aff8..854ce8c10b 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -3552,27 +3552,26 @@ class Article { __METHOD__ ); global $wgContLang; - - if( $res !== false ) { - foreach( $res as $row ) { - $tlTemplates[] = $wgContLang->getNsText( $row->tl_namespace ) . ':' . $row->tl_title ; - } + foreach( $res as $row ) { + $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true; } # Get templates from parser output. - $poTemplates_allns = $parserOutput->getTemplates(); - - $poTemplates = array (); - foreach ( $poTemplates_allns as $ns_templates ) { - $poTemplates = array_merge( $poTemplates, $ns_templates ); + $poTemplates = array(); + foreach ( $parserOutput->getTemplates() as $ns => $templates ) { + foreach ( $templates as $dbk => $id ) { + $key = $row->tl_namespace . ':'. $row->tl_title; + $poTemplates["$ns:$dbk"] = true; + } } # Get the diff - $templates_diff = array_diff( $poTemplates, $tlTemplates ); + # Note that we simulate array_diff_key in PHP <5.0.x + $templates_diff = array_diff_key( $poTemplates, $tlTemplates ); if( count( $templates_diff ) > 0 ) { # Whee, link updates time. - $u = new LinksUpdate( $this->mTitle, $parserOutput ); + $u = new LinksUpdate( $this->mTitle, $parserOutput, false ); $u->doUpdate(); } } -- 2.20.1