Merge "ProxyLookup: Optimise in_array in isConfiguredProxy()"
[lhc/web/wiklou.git] / includes / libs / virtualrest / RestbaseVirtualRESTService.php
index d31e735..f3b7872 100644 (file)
@@ -111,7 +111,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
        }
 
        /**
-        * Remaps Parsoid v1/v3 requests to RESTBase v1 requests.
+        * Remaps Parsoid v3 requests to RESTBase v1 requests.
         * @param array $reqs
         * @param Closure $idGeneratorFunc
         * @return array
@@ -123,113 +123,14 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
                        $version = explode( '/', $req['url'] )[1];
                        if ( $version === 'v3' ) {
                                $result[$key] = $this->onParsoid3Request( $req, $idGeneratorFunc );
-                       } elseif ( $version === 'v1' ) {
-                               $result[$key] = $this->onParsoid1Request( $req, $idGeneratorFunc );
                        } else {
-                               throw new Exception( "Only v1 and v3 are supported." );
+                               throw new Exception( "Only Parsoid v3 is supported." );
                        }
                }
 
                return $result;
        }
 
-       /**
-        * Remap a Parsoid v1 request to a RESTBase v1 request.
-        *
-        * Example Parsoid v1 requests:
-        *  GET /local/v1/page/$title/html/$oldid
-        *   * $oldid is optional
-        *  POST /local/v1/transform/html/to/wikitext/$title/$oldid
-        *   * body: array( 'html' => ... )
-        *   * $title and $oldid are optional
-        *  POST /local/v1/transform/wikitext/to/html/$title
-        *   * body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body' => true/false )
-        *   * $title is optional
-        *
-        * NOTE: the POST APIs aren't "real" Parsoid v1 APIs, they are just what
-        * Visual Editor "pretends" the V1 API is like.  (See
-        * ParsoidVirtualRESTService.)
-        * @param array $req
-        * @param Closure $idGeneratorFunc
-        * @return array
-        * @throws Exception
-        * @deprecated since 1.26, upgrade your client to issue v3 requests.
-        */
-       public function onParsoid1Request( array $req, Closure $idGeneratorFunc ) {
-               wfDeprecated( __METHOD__, '1.26' );
-               $parts = explode( '/', $req['url'] );
-               list(
-                       $targetWiki, // 'local'
-                       $version, // 'v1'
-                       $reqType // 'page' or 'transform'
-               ) = $parts;
-               if ( $targetWiki !== 'local' ) {
-                       throw new Exception( "Only 'local' target wiki is currently supported" );
-               } elseif ( $version !== 'v1' ) {
-                       throw new Exception( "Version mismatch: should not happen." );
-               } elseif ( $reqType !== 'page' && $reqType !== 'transform' ) {
-                       throw new Exception( "Request type must be either 'page' or 'transform'" );
-               }
-               $req['url'] = $this->params['url'] . $this->params['domain'] . '/v1/' . $reqType . '/';
-               if ( $reqType === 'page' ) {
-                       $title = $parts[3];
-                       if ( $parts[4] !== 'html' ) {
-                               throw new Exception( "Only 'html' output format is currently supported" );
-                       }
-                       $req['url'] .= 'html/' . $title;
-                       if ( isset( $parts[5] ) ) {
-                               $req['url'] .= '/' . $parts[5];
-                       } elseif ( isset( $req['query']['oldid'] ) && $req['query']['oldid'] ) {
-                               $req['url'] .= '/' . $req['query']['oldid'];
-                               unset( $req['query']['oldid'] );
-                       }
-               } elseif ( $reqType === 'transform' ) {
-                       // from / to transform
-                       $req['url'] .= $parts[3] . '/to/' . $parts[5];
-                       // the title
-                       if ( isset( $parts[6] ) ) {
-                               $req['url'] .= '/' . $parts[6];
-                       }
-                       // revision id
-                       if ( isset( $parts[7] ) ) {
-                               $req['url'] .= '/' . $parts[7];
-                       } elseif ( isset( $req['body']['oldid'] ) && $req['body']['oldid'] ) {
-                               $req['url'] .= '/' . $req['body']['oldid'];
-                               unset( $req['body']['oldid'] );
-                       }
-                       if ( $parts[4] !== 'to' ) {
-                               throw new Exception( "Part index 4 is not 'to'" );
-                       }
-                       if ( $parts[3] === 'html' && $parts[5] === 'wikitext' ) {
-                               if ( !isset( $req['body']['html'] ) ) {
-                                       throw new Exception( "You must set an 'html' body key for this request" );
-                               }
-                       } elseif ( $parts[3] == 'wikitext' && $parts[5] == 'html' ) {
-                               if ( !isset( $req['body']['wikitext'] ) ) {
-                                       throw new Exception( "You must set a 'wikitext' body key for this request" );
-                               }
-                               if ( isset( $req['body']['body'] ) ) {
-                                       $req['body']['body_only'] = $req['body']['body'];
-                                       unset( $req['body']['body'] );
-                               }
-                       } else {
-                               throw new Exception( "Transformation unsupported" );
-                       }
-               }
-               // set the appropriate proxy, timeout and headers
-               if ( $this->params['HTTPProxy'] ) {
-                       $req['proxy'] = $this->params['HTTPProxy'];
-               }
-               if ( $this->params['timeout'] != null ) {
-                       $req['reqTimeout'] = $this->params['timeout'];
-               }
-               if ( $this->params['forwardCookies'] ) {
-                       $req['headers']['Cookie'] = $this->params['forwardCookies'];
-               }
-
-               return $req;
-       }
-
        /**
         * Remap a Parsoid v3 request to a RESTBase v1 request.
         *