Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/273655

Change subject: [1.27.0-wmf.11] MF cache pollution debug log
......................................................................

[1.27.0-wmf.11] MF cache pollution debug log

Cherry-picked from wmf.10. Also expanded the match text to include
"<a" to reduce the false positive rate due to on-wiki reports.

Bug: T124356

Change-Id: I603bf6fefd069d6a19b1833d5082efdaa10a480a
(cherry picked from commit c36bbe47f4c59245fd9a60273f8c3e40d7b7071a)
---
M includes/parser/ParserCache.php
M includes/parser/ParserOutput.php
2 files changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/273655/1

diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php
index 0eba166..83cb6bf 100644
--- a/includes/parser/ParserCache.php
+++ b/includes/parser/ParserCache.php
@@ -258,6 +258,11 @@
        public function save( $parserOutput, $page, $popts, $cacheTime = null, 
$revId = null ) {
                $expire = $parserOutput->getCacheExpiry();
                if ( $expire > 0 ) {
+                       if ( strpos( $parserOutput->mText, '<a 
href="#/editor/1"' ) !== false ) {
+                               wfDebugLog( 'T124356', "MF pollution 
({$page->getId()}): getText called from: " . (
+                                       $parserOutput->debug_gettext_trace ?
+                                       implode( ', ', 
$parserOutput->debug_gettext_trace ) : 'nowhere' ) );
+                       }
                        $cacheTime = $cacheTime ?: wfTimestampNow();
                        if ( !$revId ) {
                                $revision = $page->getRevision();
diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index 656e580..d39a354 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -208,6 +208,8 @@
         */
        private $mFlags = array();
 
+       public $debug_gettext_trace = array();
+
        const EDITSECTION_REGEX =
                '#<(?:mw:)?editsection page="(.*?)" 
section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
 
@@ -232,6 +234,10 @@
        }
 
        public function getText() {
+               if ( !is_array( $this->debug_gettext_trace ) ) {
+                       $this->debug_gettext_trace = 
(array)$this->debug_gettext_trace;
+               }
+               $this->debug_gettext_trace[] = wfGetAllCallers( false );
                $text = $this->mText;
                if ( $this->mEditSectionTokens ) {
                        $text = preg_replace_callback(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I603bf6fefd069d6a19b1833d5082efdaa10a480a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.27.0-wmf.14
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to