45 if ( ( $phase & PHP_OUTPUT_HANDLER_CLEAN ) === PHP_OUTPUT_HANDLER_CLEAN ) {
46 $logger = LoggerFactory::getInstance(
'output' );
47 $logger->debug( __METHOD__ .
" entrypoint={entry}; size={size}; phase=$phase", [
49 'size' => strlen(
$s ),
56 $s = self::mangleFlashPolicy(
$s );
61 $phpHandlesCompression = (
62 ini_get(
'output_handler' ) ===
'ob_gzhandler' ||
63 ini_get(
'zlib.output_handler' ) ===
'ob_gzhandler' ||
65 strtolower( ini_get(
'zlib.output_compression' ) ),
72 !$phpHandlesCompression &&
74 !defined(
'MW_NO_OUTPUT_COMPRESSION' ) &&
78 $s = self::handleGzip(
$s );
83 !$phpHandlesCompression &&
85 !ini_get(
'output_handler' ) &&
86 !ini_get(
'zlib.output_handler' )
88 self::emitContentLength( strlen(
$s ) );
106 if ( isset( $_SERVER[
'REQUEST_URI'] ) ) {
108 $path = explode(
'?', $_SERVER[
'REQUEST_URI'], 2 )[0];
109 } elseif ( isset( $_SERVER[
'SCRIPT_NAME'] ) ) {
111 $path = $_SERVER[
'SCRIPT_NAME'];
117 $period = strrpos(
$path,
'.' );
118 if ( $period !==
false ) {
119 return strtolower( substr(
$path, $period ) );
135 if ( !function_exists(
'gzencode' ) ) {
136 wfDebug( __METHOD__ .
"() skipping compression (gzencode unavailable)" );
139 if ( headers_sent() ) {
140 wfDebug( __METHOD__ .
"() skipping compression (headers already sent)" );
144 $ext = self::findUriExtension();
145 if (
$ext ==
'.gz' ||
$ext ==
'.tgz' ) {
161 wfDebug( __METHOD__ .
"() is compressing output" );
162 header(
'Content-Encoding: gzip' );
163 $s = gzencode(
$s, 6 );
167 $headers = headers_list();
169 foreach ( $headers as
$header ) {
170 $headerName = strtolower( substr(
$header, 0, 5 ) );
171 if ( $headerName ==
'vary:' ) {
177 header(
'Vary: Accept-Encoding' );
189 # Avoid weird excessive memory usage in PCRE on big articles
190 if ( preg_match(
'/<\s*cross-domain-policy(?=\s|>)/i',
$s ) ) {
191 return preg_replace(
'/<(\s*)(cross-domain-policy(?=\s|>))/i',
'<$1NOT-$2',
$s );
213 if ( headers_sent() ) {
214 wfDebug( __METHOD__ .
"() headers already sent" );
219 in_array( http_response_code(), [ 200, 404 ],
true ) ||
220 ( $_SERVER[
'SERVER_PROTOCOL'] ??
null ) ===
'HTTP/1.0'
222 header(
"Content-Length: $length" );
$wgDisableOutputCompression
Disable output compression (enabled by default if zlib is available)
$wgMangleFlashPolicy
When OutputHandler is used, mangle any output that contains <cross-domain-policy>.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfClientAcceptsGzip( $force=false)
Whether the client accept gzip encoding.
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s
if(!is_readable( $file)) $ext