http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60864

Revision: 60864
Author:   siebrand
Date:     2010-01-09 18:10:11 +0000 (Sat, 09 Jan 2010)

Log Message:
-----------
(bug 22034) Use wfClientAcceptsGzip() in wfGzipHandler. Patch by Platonides.

wfGzipHandler should use wfClientAcceptsGzip() instead of reimplementing it. 
Patch does this and removes the $wgUseGzip check on wfClientAcceptsGzip() since 
HTMLFileCache (the only wfClientAcceptsGzip() user) already checked that before 
calling it. This way $wgUseGzip stays applying only for file cache, and 
$wgDisableOutputCompression for output handler.

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/GlobalFunctions.php
    trunk/phase3/includes/OutputHandler.php

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2010-01-09 18:02:57 UTC (rev 60863)
+++ trunk/phase3/RELEASE-NOTES  2010-01-09 18:10:11 UTC (rev 60864)
@@ -19,6 +19,7 @@
 it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 
 === Configuration changes in 1.16 ===
+
 * (bug 18222) $wgMinimalPasswordLength default is now 1
 * $wgSessionHandler can be used to configure session.save_handler
 * $wgLocalFileRepo/$wgForeignFileRepos now have a 'fileMode' parameter to
@@ -81,12 +82,12 @@
   similarly to the category namespace.
 * $wgEnableSorbs renamed to $wgDnsBlacklistUrls ($wgEnableSorbs kept for
   backward compatibility)
-* $wgUploadNavigationUrl now also affects images inline images that do not 
-  exist. In that case the URL will get (?|&)wpDestFile=<filename> appended to 
+* $wgUploadNavigationUrl now also affects images inline images that do not
+  exist. In that case the URL will get (?|&)wpDestFile=<filename> appended to
   it as appropriate.
 * If $wgLocaltimezone is null, use the server's timezone as the default for
   signatures. This was always the behaviour documented in DefaultSettings.php
-  but has not been the actual behaviour for some time: instead, UTC was used 
+  but has not been the actual behaviour for some time: instead, UTC was used
   by default.
 
 
@@ -659,10 +660,10 @@
   only displayed to the users that have "editinterface" right
 * (bug 21740) Attempting to protect a page that doesn't exist (salting) returns
   "unknown error"
-* (bug 18762) both redirects and links get fixed one after another if 
+* (bug 18762) both redirects and links get fixed one after another if
   redirects-only switch is not present
 * (bug 20159) thumbnails rerendered if older that $wgThumbnailEpoch
-* Fixed a bug which in some situations causes the job queue to grow forever, 
+* Fixed a bug which in some situations causes the job queue to grow forever,
   due to an infinite loop of job requeues.
 * (bug 21523) File that can have multiple pages (djvu, pdf, ...) no longer have
   the page selector when they have only one page
@@ -693,6 +694,8 @@
 * (bug 2658) Don't attempt to set the TZ environment variable.
 * (bug 9794) User rights log entries for foreign user now links to the foreign
   user's page if possible
+* (bug 22034) Use wfClientAcceptsGzip() in wfGzipHandler instead of
+  reimplementing it.
 
 == API changes in 1.16 ==
 
@@ -763,8 +766,8 @@
 * (bug 21441) meta=userinfo&uiprop=options no longer returns default options
   for logged-in users under certain circumstances
 * (bug 21945) Add chomp control in YAML
-* Expand the thumburl to an absolute url to make it consistent with url and 
-  descriptionurl 
+* Expand the thumburl to an absolute url to make it consistent with url and
+  descriptionurl
 * (bug 20233) ApiLogin::execute() doesn't handle LoginForm :: RESET_PASS
 
 === Languages updated in 1.16 ===

Modified: trunk/phase3/includes/GlobalFunctions.php
===================================================================
--- trunk/phase3/includes/GlobalFunctions.php   2010-01-09 18:02:57 UTC (rev 
60863)
+++ trunk/phase3/includes/GlobalFunctions.php   2010-01-09 18:10:11 UTC (rev 
60864)
@@ -1168,17 +1168,15 @@
  */
 function wfClientAcceptsGzip() {
        global $wgUseGzip;
-       if( $wgUseGzip ) {
-               # FIXME: we may want to blacklist some broken browsers
-               $m = array();
-               if( preg_match(
-                       '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
-                       $_SERVER['HTTP_ACCEPT_ENCODING'],
-                       $m ) ) {
-                       if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 
) ) return false;
-                       wfDebug( " accepts gzip\n" );
-                       return true;
-               }
+       # FIXME: we may want to blacklist some broken browsers
+       $m = array();
+       if( preg_match(
+               '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
+               $_SERVER['HTTP_ACCEPT_ENCODING'],
+               $m ) ) {
+               if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) 
return false;
+               wfDebug( " accepts gzip\n" );
+               return true;
        }
        return false;
 }

Modified: trunk/phase3/includes/OutputHandler.php
===================================================================
--- trunk/phase3/includes/OutputHandler.php     2010-01-09 18:02:57 UTC (rev 
60863)
+++ trunk/phase3/includes/OutputHandler.php     2010-01-09 18:10:11 UTC (rev 
60864)
@@ -74,12 +74,9 @@
                return $s;
        }
 
-       if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
-               $tokens = preg_split( '/[,; ]/', 
$_SERVER['HTTP_ACCEPT_ENCODING'] );
-               if ( in_array( 'gzip', $tokens ) ) {
-                       header( 'Content-Encoding: gzip' );
-                       $s = gzencode( $s, 6 );
-               }
+       if( wfClientAcceptsGzip() ) {
+               header( 'Content-Encoding: gzip' );
+               $s = gzencode( $s, 6 );
        }
 
        // Set vary header if it hasn't been set already



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to