Hello Aaron Schulz, Krinkle, jenkins-bot,

I'd like you to do a code review.  Please visit

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

to review the following change.


Change subject: Revert "Make Revision::getRevisionText() cache the converted 
text"
......................................................................

Revert "Make Revision::getRevisionText() cache the converted text"

fails on beta update.php with:
Fatal error: Call to undefined method ExternalStore::decompressRevisionText() 
in /srv/mediawiki-staging/php-master/includes/Revision.php on line 1290
Guess ExternalStore::decompressRevisionText does not exist.

This reverts commit df3d46e57f0030cf0edbe2a9c91c8d4787908bee.

Bug: T158084
Bug: T161037
Change-Id: I52c2b359b4a995c00a5111b419041aa09f291e0e
---
M includes/Revision.php
1 file changed, 11 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/06/344106/1

diff --git a/includes/Revision.php b/includes/Revision.php
index a3dbc14..dca2e1b 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -1279,15 +1279,12 @@
                        if ( isset( $row->old_id ) && $wiki === false ) {
                                // Make use of the wiki-local revision text 
cache
                                $cache = 
MediaWikiServices::getInstance()->getMainWANObjectCache();
-                               // The cached value should be decompressed, so 
handle that and return here
-                               return $cache->getWithSetCallback(
+                               $text = $cache->getWithSetCallback(
                                        $cache->makeKey( 'revisiontext', 
'textid', $row->old_id ),
                                        self::getCacheTTL( $cache ),
-                                       function () use ( $url, $wiki, $flags ) 
{
+                                       function () use ( $url, $wiki ) {
                                                // No negative caching per 
Revision::loadText()
-                                               $text = 
ExternalStore::fetchFromURL( $url, [ 'wiki' => $wiki ] );
-
-                                               return 
ExternalStore::decompressRevisionText( $text, $flags );
+                                               return 
ExternalStore::fetchFromURL( $url, [ 'wiki' => $wiki ] );
                                        },
                                        [ 'pcGroup' => self::TEXT_CACHE_GROUP, 
'pcTTL' => $cache::TTL_PROC_LONG ]
                                );
@@ -1296,7 +1293,12 @@
                        }
                }
 
-               return self::decompressRevisionText( $text, $flags );
+               // If the text was fetched without an error, convert it
+               if ( $text !== false ) {
+                       $text = self::decompressRevisionText( $text, $flags );
+               }
+
+               return $text;
        }
 
        /**
@@ -1342,13 +1344,6 @@
         * @return string|bool Decompressed text, or false on failure
         */
        public static function decompressRevisionText( $text, $flags ) {
-               global $wgLegacyEncoding, $wgContLang;
-
-               if ( $text === false ) {
-                       // Text failed to be fetched; nothing to do
-                       return false;
-               }
-
                if ( in_array( 'gzip', $flags ) ) {
                        # Deal with optional compression of archived pages.
                        # This can be done periodically via 
maintenance/compressOld.php, and
@@ -1371,6 +1366,7 @@
                        $text = $obj->getText();
                }
 
+               global $wgLegacyEncoding;
                if ( $text !== false && $wgLegacyEncoding
                        && !in_array( 'utf-8', $flags ) && !in_array( 'utf8', 
$flags )
                ) {
@@ -1378,6 +1374,7 @@
                        # Upconvert on demand.
                        # ("utf8" checked for compatibility with some broken
                        #  conversion scripts 2008-12-30)
+                       global $wgContLang;
                        $text = $wgContLang->iconv( $wgLegacyEncoding, 'UTF-8', 
$text );
                }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I52c2b359b4a995c00a5111b419041aa09f291e0e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to