r106818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106817‎ | r106818 | r106819 >
Date:17:22, 20 December 2011
Author:catrope
Status:ok
Tags:
Comment:
Simplify the code a bit and add a FIXME comment
Modified paths:
  • /trunk/tools/web-scripts/missing.php (modified) (history)

Diff [purge]

Index: trunk/tools/web-scripts/missing.php
@@ -26,17 +26,13 @@
2727 */
2828 function getSelfUrl() {
2929
30 - /* faking https on secure.wikimedia.org - thanks Ryan for hint */
 30+ // faking https on secure.wikimedia.org - thanks Ryan for hint
3131 if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
3232 $_SERVER['HTTPS'] = 'on';
3333 }
3434
35 - $s = empty( $_SERVER['HTTPS'] ) ? '' : ( $_SERVER['HTTPS'] == 'on' ) ? 's' : '';
36 -
37 - $protocol = substr( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 0, strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), '/' ) ) . $s;
38 -
39 - $port = ( $_SERVER['SERVER_PORT'] == '80') ? '' : ( ':' . $_SERVER['SERVER_PORT'] );
40 -
 35+ $protocol = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ? 'https' : 'http';
 36+ $port = ( $_SERVER['SERVER_PORT'] == '80' ) ? '' : ( ':' . $_SERVER['SERVER_PORT'] );
4137 return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
4238 }
4339
@@ -55,6 +51,7 @@
5652
5753 $url = parse_url( getSelfUrl() );
5854
 55+// FIXME: the code below assumes getSelfUrl() contains /wiki/ , it should verify that
5956 if( $url['host'] == 'secure.wikimedia.org' ) {
6057
6158 # https://secure.wikimedia.org/$project/$language/wiki/$page

Status & tagging log