r111689 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111688‎ | r111689 | r111690 >
Date:22:12, 16 February 2012
Author:awjrichards
Status:ok (Comments)
Tags:
Comment:
Removes hardcoded 'wikimedia.org' when checking the proxy server before attempting to set no-cache headers. Now instead fetches raw IP and checks if it's a trusted proxy with wfIsTrustedProxy(). per bug 34145
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.body.php
@@ -710,15 +710,23 @@
711711 return $url;
712712 }
713713
 714+ /**
 715+ * Disables caching if the request is coming from a trusted proxy
 716+ */
714717 private function disableCaching() {
715718 global $wgRequest;
716719 wfProfileIn( __METHOD__ );
717 - if ( isset( $_SERVER['HTTP_VIA'] ) &&
718 - stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' ) !== false ) {
 720+
 721+ // Fetch the REMOTE_ADDR and check if it's a trusted proxy.
 722+ // Is this enough, or should we actually step through the entire
 723+ // X-FORWARDED-FOR chain?
 724+ $ip = $wgRequest->getRawIP();
 725+ if ( wfIsTrustedProxy ( $ip )) {
719726 $wgRequest->response()->header( 'Cache-Control: no-cache, must-revalidate' );
720727 $wgRequest->response()->header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
721728 $wgRequest->response()->header( 'Pragma: no-cache' );
722729 }
 730+
723731 wfProfileOut( __METHOD__ );
724732 return true;
725733 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r111746Fix for PHP Fatal error: Call to protected method WebRequest::getRawIP() fro...preilly12:33, 17 February 2012
r111777Removed usage of wfGetIP() and now just fetching IP from [REMOTE_ADDR], follo...awjrichards19:28, 17 February 2012

Comments

#Comment by Preilly (talk | contribs)   12:35, 17 February 2012

Just one small fix for the following PHP Fatal error: Call to protected method WebRequest::getRawIP() from context 'ExtMobileFrontend' in MobileFrontend.body.php on line 723 Switched from using getRawIP() to wfGetIP();

Status & tagging log