Revert 60864: "Use wfClientAcceptsGzip() in wfGzipHandler." Causes PHP Notice: Undefined index: HTTP_ACCEPT_ENCODING in GlobalFunctions.php on line 1175

This commit is contained in:
Siebrand Mazeland 2010-01-09 19:14:43 +00:00
parent 29e47fa366
commit 7c27e42fb8
3 changed files with 24 additions and 22 deletions

View file

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

View file

@ -1168,15 +1168,17 @@ function wfNumLink( $offset, $limit, $title, $query = '' ) {
*/ */
function wfClientAcceptsGzip() { function wfClientAcceptsGzip() {
global $wgUseGzip; global $wgUseGzip;
# FIXME: we may want to blacklist some broken browsers if( $wgUseGzip ) {
$m = array(); # FIXME: we may want to blacklist some broken browsers
if( preg_match( $m = array();
'/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', if( preg_match(
$_SERVER['HTTP_ACCEPT_ENCODING'], '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
$m ) ) { $_SERVER['HTTP_ACCEPT_ENCODING'],
if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) return false; $m ) ) {
wfDebug( " accepts gzip\n" ); if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) return false;
return true; wfDebug( " accepts gzip\n" );
return true;
}
} }
return false; return false;
} }

View file

@ -74,9 +74,12 @@ function wfGzipHandler( $s ) {
return $s; return $s;
} }
if( wfClientAcceptsGzip() ) { if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
header( 'Content-Encoding: gzip' ); $tokens = preg_split( '/[,; ]/', $_SERVER['HTTP_ACCEPT_ENCODING'] );
$s = gzencode( $s, 6 ); if ( in_array( 'gzip', $tokens ) ) {
header( 'Content-Encoding: gzip' );
$s = gzencode( $s, 6 );
}
} }
// Set vary header if it hasn't been set already // Set vary header if it hasn't been set already