Fix fatal error when $wgValidateAllHtml is enabled and apache_request_headers() does...
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Tue, 14 May 2013 05:57:34 +0000 (07:57 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 25 Jul 2013 10:05:13 +0000 (12:05 +0200)
Changed apache_request_headers() to headers_list() since the latter is always available

Change-Id: Ia52f5a0d12db0680aa03b57dd45c974291e88af9

RELEASE-NOTES-1.22
includes/OutputHandler.php

index c1f91bc..0b1cc17 100644 (file)
@@ -218,6 +218,8 @@ production.
 * (bug 50870) mediawiki.notification: Notification area should remain visible
   when scrolled down.
 * (bug 13438) Special:MIMESearch no longer an expensive special page.
+* (bug 48342) Fixed a fatal error when $wgValidateAllHtml is set to true and
+  the function apache_request_headers() function is not available.
 
 === API changes in 1.22 ===
 * (bug 25553) The JSON output formatter now leaves forward slashes unescaped
index 5104a1a..3860b8e 100644 (file)
@@ -31,11 +31,19 @@ function wfOutputHandler( $s ) {
        global $wgDisableOutputCompression, $wgValidateAllHtml;
        $s = wfMangleFlashPolicy( $s );
        if ( $wgValidateAllHtml ) {
-               $headers = apache_response_headers();
-               $isHTML = true;
-               foreach ( $headers as $name => $value ) {
-                       if ( strtolower( $name ) == 'content-type' && strpos( $value, 'text/html' ) === false && strpos( $value, 'application/xhtml+xml' ) === false ) {
-                               $isHTML = false;
+               $headers = headers_list();
+               $isHTML = false;
+               foreach ( $headers as $header ) {
+                       $parts = explode( ':', $header, 2 );
+                       if ( count( $parts ) !== 2 ) {
+                               continue;
+                       }
+                       $name = strtolower( trim( $parts[0] ) );
+                       $value = trim( $parts[1] );
+                       if ( $name == 'content-type' && ( strpos( $value, 'text/html' ) === 0
+                               || strpos( $value, 'application/xhtml+xml' ) === 0 )
+                       ) {
+                               $isHTML = true;
                                break;
                        }
                }