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

Change subject: Drop calls to WikiPage->getText
......................................................................


Drop calls to WikiPage->getText

Fix false positive template matches in shouldShowNoIndex
(We should remove or start using this method.)

Bug: T145751
Change-Id: I4b2b5e6c52ab43fa8e368f8dae0a124468b4ca64
---
M PageTriage.hooks.php
M includes/ArticleMetadata.php
2 files changed, 20 insertions(+), 10 deletions(-)

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



diff --git a/PageTriage.hooks.php b/PageTriage.hooks.php
index a84e86b..9525dbd 100755
--- a/PageTriage.hooks.php
+++ b/PageTriage.hooks.php
@@ -251,6 +251,7 @@
                }
        }
 
+       // This method is currently unused.
        /**
         * Determines whether to show no-index for the article specified, show 
no-index if
         * 1. the page contains a template listed in 
$wgPageTriageNoIndexTemplates page
@@ -266,7 +267,8 @@
                        if ( $noIndexTitle ) {
                                $noIndexArticle = WikiPage::newFromID( 
$noIndexTitle->getArticleID() );
                                if ( $noIndexArticle ) {
-                                       $noIndexTemplateText = 
$noIndexArticle->getText();
+                                       $noIndexTemplateContent = 
$noIndexArticle->getContent();
+                                       $noIndexTemplateText = 
ContentHandler::getContentText( $noIndexTemplateContent );
                                        if ( $noIndexTemplateText ) {
                                                // Collect all the noindex 
template names into an array
                                                $noIndexTemplates = explode( 
'|', $noIndexTemplateText );
@@ -275,11 +277,18 @@
                                                        [ 'PageTriageHooks', 
'formatTemplateName' ],
                                                        $noIndexTemplates
                                                );
-                                               foreach ( 
$article->mParserOutput->getTemplates() as $templates ) {
-                                                       foreach ( $templates as 
$template => $pageId ) {
-                                                               if ( in_array( 
$template, $noIndexTemplates ) ) {
-                                                                       return 
true;
-                                                               }
+
+                                               // getTemplates returns all 
transclusions, not just NS_TEMPLATE
+                                               // But the MW page does not 
include the namespace.
+                                               $allTransclusions = 
$article->mParserOutput->getTemplates();
+
+                                               $templates = isset( 
$allTransclusions[NS_TEMPLATE] ) ?
+                                                       
$allTransclusions[NS_TEMPLATE] :
+                                                       [];
+
+                                               foreach ( $templates as 
$template => $pageId ) {
+                                                       if ( in_array( 
$template, $noIndexTemplates ) ) {
+                                                               return true;
                                                        }
                                                }
                                        }
diff --git a/includes/ArticleMetadata.php b/includes/ArticleMetadata.php
index 6e8d4bc..75d1d3a 100755
--- a/includes/ArticleMetadata.php
+++ b/includes/ArticleMetadata.php
@@ -725,10 +725,11 @@
                                $article = WikiPage::newFromID( $pageId, $from 
);
                        }
                        if ( $article ) {
-                               $content = $article->getText();
-                               if ( $content ) {
-                                       $this->metadata[$pageId]['snippet'] = 
self::generateArticleSnippet( $content );
-                                       $this->metadata[$pageId]['reference'] = 
self::checkReferenceTag( $content );
+                               $content = $article->getContent();
+                               $text = ContentHandler::getContentText( 
$content );
+                               if ( $text ) {
+                                       $this->metadata[$pageId]['snippet'] = 
self::generateArticleSnippet( $text );
+                                       $this->metadata[$pageId]['reference'] = 
self::checkReferenceTag( $text );
                                }
                        }
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4b2b5e6c52ab43fa8e368f8dae0a124468b4ca64
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/PageTriage
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Mattflaschen <mflasc...@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