AutoloadGenerator: Don't throw MWExceptions
[lhc/web/wiklou.git] / includes / WebRequest.php
index a1fa0eb..bf99e95 100644 (file)
@@ -181,7 +181,12 @@ class WebRequest {
                                continue;
                        }
                        $host = $parts[0];
-                       if ( $parts[1] === false ) {
+                       if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) {
+                               // Bug 70021: Assume that upstream proxy is running on the default
+                               // port based on the protocol. We have no reliable way to determine
+                               // the actual port in use upstream.
+                               $port = $stdPort;
+                       } elseif ( $parts[1] === false ) {
                                if ( isset( $_SERVER['SERVER_PORT'] ) ) {
                                        $port = $_SERVER['SERVER_PORT'];
                                } // else leave it as $stdPort
@@ -700,21 +705,22 @@ class WebRequest {
 
        /**
         * Take an arbitrary query and rewrite the present URL to include it
+        * @deprecated Use appendQueryValue/appendQueryArray instead
         * @param string $query Query string fragment; do not include initial '?'
-        *
         * @return string
         */
        public function appendQuery( $query ) {
+               wfDeprecated( __METHOD__, '1.25' );
                return $this->appendQueryArray( wfCgiToArray( $query ) );
        }
 
        /**
         * @param string $key
         * @param string $value
-        * @param bool $onlyquery
+        * @param bool $onlyquery [deprecated]
         * @return string
         */
-       public function appendQueryValue( $key, $value, $onlyquery = false ) {
+       public function appendQueryValue( $key, $value, $onlyquery = true ) {
                return $this->appendQueryArray( array( $key => $value ), $onlyquery );
        }
 
@@ -722,16 +728,21 @@ class WebRequest {
         * Appends or replaces value of query variables.
         *
         * @param array $array Array of values to replace/add to query
-        * @param bool $onlyquery Whether to only return the query string and not the complete URL
+        * @param bool $onlyquery Whether to only return the query string and not the complete URL [deprecated]
         * @return string
         */
-       public function appendQueryArray( $array, $onlyquery = false ) {
+       public function appendQueryArray( $array, $onlyquery = true ) {
                global $wgTitle;
                $newquery = $this->getQueryValues();
                unset( $newquery['title'] );
                $newquery = array_merge( $newquery, $array );
                $query = wfArrayToCgi( $newquery );
-               return $onlyquery ? $query : $wgTitle->getLocalURL( $query );
+               if ( !$onlyquery ) {
+                       wfDeprecated( __METHOD__, '1.25' );
+                       return $wgTitle->getLocalURL( $query );
+               }
+
+               return $query;
        }
 
        /**
@@ -1250,6 +1261,7 @@ class WebRequestUpload {
 class FauxRequest extends WebRequest {
        private $wasPosted = false;
        private $session = array();
+       private $requestUrl;
 
        /**
         * @param array $data Array of *non*-urlencoded key => value pairs, the
@@ -1329,8 +1341,15 @@ class FauxRequest extends WebRequest {
                return false;
        }
 
+       public function setRequestURL( $url ) {
+               $this->requestUrl = $url;
+       }
+
        public function getRequestURL() {
-               $this->notImplemented( __METHOD__ );
+               if ( $this->requestUrl === null ) {
+                       throw new MWException( 'Request URL not set' );
+               }
+               return $this->requestUrl;
        }
 
        public function getProtocol() {