Merge "Revert "Do not encode "'" as %27 (redirect loop in Opera 12)""
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index b853d07..2852561 100644 (file)
@@ -2179,14 +2179,24 @@ function wfResetOutputBuffers( $resetGzipEncoding = true ) {
                $wgDisableOutputCompression = true;
        }
        while ( $status = ob_get_status() ) {
-               if ( $status['type'] == 0 /* PHP_OUTPUT_HANDLER_INTERNAL */ ) {
-                       // Probably from zlib.output_compression or other
-                       // PHP-internal setting which can't be removed.
-                       //
+               if ( isset( $status['flags'] ) ) {
+                       $flags = PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_REMOVABLE;
+                       $deleteable = ( $status['flags'] & $flags ) === $flags;
+               } elseif ( isset( $status['del'] ) ) {
+                       $deleteable = $status['del'];
+               } else {
+                       // Guess that any PHP-internal setting can't be removed.
+                       $deleteable = $status['type'] !== 0; /* PHP_OUTPUT_HANDLER_INTERNAL */
+               }
+               if ( !$deleteable ) {
                        // Give up, and hope the result doesn't break
                        // output behavior.
                        break;
                }
+               if ( $status['name'] === 'MediaWikiTestCase::wfResetOutputBuffersBarrier' ) {
+                       // Unit testing barrier to prevent this function from breaking PHPUnit.
+                       break;
+               }
                if ( !ob_end_clean() ) {
                        // Could not remove output buffer handler; abort now
                        // to avoid getting in some kind of infinite loop.