/* static */ function getRevisionText( $row, $prefix = "old_" ) {
# Deal with optional compression of archived pages.
- # This can be done periodically via maintenance/compressOld.php
+ # This can be done periodically via maintenance/compressOld.php, and
+ # as pages are saved if $wgCompressRevisions is set.
$text = $prefix . "text";
$flags = $prefix . "flags";
if( isset( $row->$flags ) && (false !== strpos( $row->$flags, "gzip" ) ) ) {
return false;
}
+ /* static */ function compressRevisionText( &$text ) {
+ global $wgCompressRevisions;
+ if( !$wgCompressRevisions ) {
+ return "";
+ }
+ if( !function_exists( "gzdeflate" ) ) {
+ wfDebug( "Article::compressRevisionText() -- no zlib support, not compressing\n" );
+ return "";
+ }
+ $text = gzdeflate( $text );
+ return "gzip";
+ }
+
# Note that getContent/loadContent may follow redirects if
# not told otherwise, and so may cause a change to mTitle.
return false;
}
+ # This overwrites $oldtext if revision compression is on
+ $flags = Article::compressRevisionText( $oldtext );
+
$sql = "INSERT INTO old (old_namespace,old_title,old_text," .
"old_comment,old_user,old_user_text,old_timestamp," .
- "old_minor_edit,inverse_timestamp) VALUES (" .
+ "old_minor_edit,inverse_timestamp,old_flags) VALUES (" .
$this->mTitle->getNamespace() . ", '" .
wfStrencode( $this->mTitle->getDBkey() ) . "', '" .
wfStrencode( $oldtext ) . "', '" .
$this->getUser() . ", '" .
wfStrencode( $this->getUserText() ) . "', '" .
$this->getTimestamp() . "', " . $me1 . ", '" .
- wfInvertTimestamp( $this->getTimestamp() ) . "')";
+ wfInvertTimestamp( $this->getTimestamp() ) . "','$flags')";
$res = wfQuery( $sql, DB_WRITE, $fname );
$oldid = wfInsertID( $res );
# We can serve pages compressed in order to save bandwidth,
# but this will increase CPU usage.
# Requires zlib support enabled in PHP.
-$wgUseGzip = false;
+$wgUseGzip = function_exists( "gzencode" );
+
+# We can also compress text in the old revisions table. If this is set on,
+# old revisions will be compressed on page save if zlib support is available.
+# Any compressed revisions will be decompressed on load regardless of this
+# setting *but will not be readable at all* if zlib support is not available.
+$wgCompressRevisions = false;
# This is the list of preferred extensions for uploading files. Uploading
# files with extensions not in this list will trigger a warning.