jenkins-bot has submitted this change and it was merged. Change subject: Add "touch.php" for $wgAppleTouchIcon... ......................................................................
Add "touch.php" for $wgAppleTouchIcon... Change-Id: I6f83e6edfade9ed8669ed9c1cc5734dee18ebf59 --- A w/touch.php 1 file changed, 49 insertions(+), 0 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/w/touch.php b/w/touch.php new file mode 100644 index 0000000..8cb58e0 --- /dev/null +++ b/w/touch.php @@ -0,0 +1,49 @@ +<?php +define( "MEDIAWIKI", true ); + +require( "/apache/common/w/MWVersion.php" ); +require( getMediaWiki( "includes/WebStart.php" ) ); + +function faviconShowError( $html ) { + header( 'Content-Type: text/html; charset=utf-8' ); + echo "<html><body>$html</body></html>\n"; +} + +function streamAppleTouch() { + global $wgAppleTouchIcon; + wfResetOutputBuffers(); + if ( $wgAppleTouchIcon === false ) { + # That's not very helpful, that's where we are already + header( 'HTTP/1.1 404 Not Found' ); + faviconShowError( "\$wgAppleTouchIcon is configured incorrectly, " . + "it must be set to something other than false \n" ); + return; + } + + $req = RequestContext::getMain()->getRequest(); + if ( $req->getHeader( 'X-Favicon-Loop' ) !== false ) { + header( 'HTTP/1.1 500 Internal Server Error' ); + faviconShowError( "Proxy forwarding loop detected" ); + return; + } + + $url = wfExpandUrl( $wgAppleTouchIcon, PROTO_INTERNAL ); + $client = MWHttpRequest::factory( $url ); + $client->setHeader( 'X-Favicon-Loop', '1' ); + + $status = $client->execute(); + if ( !$status->isOK() ) { + header( 'HTTP/1.1 500 Internal Server Error' ); + faviconShowError( htmlspecialchars( "Failed to fetch URL \"$url\"" ) ); + return; + } + + $content = $client->getContent(); + header( 'Content-Length: ' . strlen( $content ) ); + header( 'Content-Type: ' . $client->getResponseHeader( 'Content-Type' ) ); + header( 'Cache-Control: public' ); + header( 'Expires: ' . gmdate( 'r', time() + 86400 ) ); + echo $content; +} + +streamAppleTouch(); -- To view, visit https://gerrit.wikimedia.org/r/90886 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6f83e6edfade9ed8669ed9c1cc5734dee18ebf59 Gerrit-PatchSet: 2 Gerrit-Project: operations/mediawiki-config Gerrit-Branch: master Gerrit-Owner: Reedy <re...@wikimedia.org> Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits