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

Change subject: Much simpler and more performant way to handle noindexing 
templates
......................................................................


Much simpler and more performant way to handle noindexing templates

PageAssessments is only used by 1 wiki (enwiki), which only has a
single noindexing template (db-meta). There's no reason we need to
have a complicated on-wiki configuration system for this that
requires checking a MediaWiki page on every non-cached pageview.
Switching to a regular config variable system instead.

Note that $wgPageTriageNoIndexTemplates is currently not set in any
wmf-config files, so there's no danger from switching the type here.

Change-Id: I115a606f5dfc699790497bcfc59e6ea83160d851
---
M PageTriage.hooks.php
M PageTriage.php
2 files changed, 17 insertions(+), 30 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/PageTriage.hooks.php b/PageTriage.hooks.php
index 63ff02e..1684b59 100755
--- a/PageTriage.hooks.php
+++ b/PageTriage.hooks.php
@@ -269,35 +269,22 @@
 
                // See if article includes any templates that should trigger 
noindexing
                if ( $wgPageTriageNoIndexTemplates && $article->mParserOutput 
instanceof ParserOutput ) {
-                       $noIndexTitle = Title::newFromText( 
$wgPageTriageNoIndexTemplates, NS_MEDIAWIKI );
-                       if ( $noIndexTitle ) {
-                               $noIndexArticle = WikiPage::newFromID( 
$noIndexTitle->getArticleID() );
-                               if ( $noIndexArticle ) {
-                                       $noIndexTemplateContent = 
$noIndexArticle->getContent();
-                                       $noIndexTemplateText = 
ContentHandler::getContentText( $noIndexTemplateContent );
-                                       if ( $noIndexTemplateText ) {
-                                               // Collect all the noindex 
template names into an array
-                                               $noIndexTemplates = explode( 
'|', $noIndexTemplateText );
-                                               // Properly format the template 
names to match what getTemplates() returns
-                                               $noIndexTemplates = array_map(
-                                                       [ 'PageTriageHooks', 
'formatTemplateName' ],
-                                                       $noIndexTemplates
-                                               );
+                       // Properly format the template names to match what 
getTemplates() returns
+                       $noIndexTemplates = array_map(
+                               [ 'PageTriageHooks', 'formatTemplateName' ],
+                               $wgPageTriageNoIndexTemplates
+                       );
 
-                                               // getTemplates returns all 
transclusions, not just NS_TEMPLATE
-                                               // But the MediaWiki page does 
not include the namespace.
-                                               $allTransclusions = 
$article->mParserOutput->getTemplates();
+                       // getTemplates returns all transclusions, not just 
NS_TEMPLATE
+                       $allTransclusions = 
$article->mParserOutput->getTemplates();
 
-                                               $templates = isset( 
$allTransclusions[NS_TEMPLATE] ) ?
-                                                       
$allTransclusions[NS_TEMPLATE] :
-                                                       [];
+                       $templates = isset( $allTransclusions[NS_TEMPLATE] ) ?
+                               $allTransclusions[NS_TEMPLATE] :
+                               [];
 
-                                               foreach ( $templates as 
$template => $pageId ) {
-                                                       if ( in_array( 
$template, $noIndexTemplates ) ) {
-                                                               return true;
-                                                       }
-                                               }
-                                       }
+                       foreach ( $templates as $template => $pageId ) {
+                               if ( in_array( $template, $noIndexTemplates ) ) 
{
+                                       return true;
                                }
                        }
                }
diff --git a/PageTriage.php b/PageTriage.php
index ff69f81..a9acaf1 100644
--- a/PageTriage.php
+++ b/PageTriage.php
@@ -62,10 +62,10 @@
 $wgPageTriageStickyStatsNav = true;
 // 1 day - How long after visiting Special:NewPagesFeed do we show review 
links on articles
 $wgPageTriageMarkPatrolledLinkExpiry = 3600 * 24;
-// Title of page in MediaWiki namespace containing a list of templates that 
will
-// trigger noindexing of pages, e.g. speedy deletion templates. Set this to 
false
-// to disable this feature.
-$wgPageTriageNoIndexTemplates = 'Noindex templates';
+// Array of template names (without prefixes) that will trigger noindexing of
+// pages that include them, for example, speedy deletion templates. Note that
+// it isn't necessary to list redirects or subtemplates.
+$wgPageTriageNoIndexTemplates = [];
 // Set this to true if new, unreviewed articles should be set to noindex. In 
other
 // words, if they should not be indexed by search engines until they are 
reviewed.
 $wgPageTriageNoIndexUnreviewedNewArticles = false;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I115a606f5dfc699790497bcfc59e6ea83160d851
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageTriage
Gerrit-Branch: master
Gerrit-Owner: Kaldari <rkald...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@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