Introduce WebRequest::getProtocol()
authorTim Starling <tstarling@wikimedia.org>
Wed, 21 Aug 2013 05:35:40 +0000 (15:35 +1000)
committerMax Semenik <maxsem.wiki@gmail.com>
Wed, 6 Nov 2013 17:13:10 +0000 (21:13 +0400)
commit8af1c9503d59b0ef2fa4fef39b2fa8be2d9323c8
tree4f95715f995108fdc22275639af4be21bddabd16
parent958a08f1b2408e4b672620c3277f734eca0247d6
Introduce WebRequest::getProtocol()

The use of static server detection outside of its intended use case
(i.e. at the start of DefaultSettings.php), for example in r93258, was
an architectural error. Every other bit of information about the web
request in non-setup code comes from non-static methods of WebRequest,
which allows the request object to be meaningfully replaced or
subclassed. The situation became increasingly ridiculous as more
callers of WebRequest::detectProtocol() were introduced. Two of the
callers were calling it non-statically! I suppose they had the right
idea, in a way.

Using a non-static call allows caching, which is a nice additional
benefit.

WebRequest::detectProtocolAndStdPort() was introduced in r93258 as part of
the introduction of WebRequest::detectProtocol(). It was basically
useless. Grep indicates there was only one caller in core and WMF
deployed extensions, and it is patched here.

Change-Id: Ia0a61e98fbff7a46ceaeebcb02236e5eac3df0e1
includes/GlobalFunctions.php
includes/WebRequest.php
includes/Wiki.php
includes/specials/SpecialUserlogin.php
tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php