jenkins-bot has submitted this change and it was merged.
Change subject: Make revision content decompression publicly available
......................................................................
Make revision content decompression publicly available
compressRevisionText() is already publicly available, but the decompression was
not. For others using compressRevisionText(), the only way to decompress was to
duplicate the gzinflate code.
Change-Id: I61cd87acb52a482ba88f7c9d3826ecee66c89911
---
M includes/Revision.php
1 file changed, 41 insertions(+), 29 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, approved
Parent5446: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/includes/Revision.php b/includes/Revision.php
index b3b971b..ddcaf17 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -1205,35 +1205,7 @@
// If the text was fetched without an error, convert it
if ( $text !== false ) {
- if ( in_array( 'gzip', $flags ) ) {
- # Deal with optional compression of archived
pages.
- # This can be done periodically via
maintenance/compressOld.php, and
- # as pages are saved if $wgCompressRevisions is
set.
- $text = gzinflate( $text );
- }
-
- if ( in_array( 'object', $flags ) ) {
- # Generic compressed storage
- $obj = unserialize( $text );
- if ( !is_object( $obj ) ) {
- // Invalid object
- wfProfileOut( __METHOD__ );
- return false;
- }
- $text = $obj->getText();
- }
-
- global $wgLegacyEncoding;
- if ( $text !== false && $wgLegacyEncoding
- && !in_array( 'utf-8', $flags ) && !in_array(
'utf8', $flags ) )
- {
- # Old revisions kept around in a legacy
encoding?
- # Upconvert on demand.
- # ("utf8" checked for compatibility with some
broken
- # conversion scripts 2008-12-30)
- global $wgContLang;
- $text = $wgContLang->iconv( $wgLegacyEncoding,
'UTF-8', $text );
- }
+ $text = self::decompressRevisionText( $text, $flags );
}
wfProfileOut( __METHOD__ );
return $text;
@@ -1269,6 +1241,46 @@
}
/**
+ * Re-converts revision text according to it's flags.
+ *
+ * @param $text Mixed: reference to a text
+ * @param $flags array: compression flags
+ * @return String|bool decompressed text, or false on failure
+ */
+ public static function decompressRevisionText( $text, $flags ) {
+ if ( in_array( 'gzip', $flags ) ) {
+ # Deal with optional compression of archived pages.
+ # This can be done periodically via
maintenance/compressOld.php, and
+ # as pages are saved if $wgCompressRevisions is set.
+ $text = gzinflate( $text );
+ }
+
+ if ( in_array( 'object', $flags ) ) {
+ # Generic compressed storage
+ $obj = unserialize( $text );
+ if ( !is_object( $obj ) ) {
+ // Invalid object
+ return false;
+ }
+ $text = $obj->getText();
+ }
+
+ global $wgLegacyEncoding;
+ if ( $text !== false && $wgLegacyEncoding
+ && !in_array( 'utf-8', $flags ) && !in_array( 'utf8',
$flags ) )
+ {
+ # Old revisions kept around in a legacy encoding?
+ # Upconvert on demand.
+ # ("utf8" checked for compatibility with some broken
+ # conversion scripts 2008-12-30)
+ global $wgContLang;
+ $text = $wgContLang->iconv( $wgLegacyEncoding, 'UTF-8',
$text );
+ }
+
+ return $text;
+ }
+
+ /**
* Insert a new revision into the database, returning the new revision
ID
* number on success and dies horribly on failure.
*
--
To view, visit https://gerrit.wikimedia.org/r/78079
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I61cd87acb52a482ba88f7c9d3826ecee66c89911
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: EBernhardson (WMF) <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits