Merge "HTMLForm: Implement OOUI version of HTMLTagFilter"
[lhc/web/wiklou.git] / includes / http / PhpHttpRequest.php
index f422ff7..3f3803b 100644 (file)
@@ -17,7 +17,6 @@
  *
  * @file
  */
-use MediaWiki\Logger\LoggerFactory;
 
 class PhpHttpRequest extends MWHttpRequest {
 
@@ -88,15 +87,20 @@ class PhpHttpRequest extends MWHttpRequest {
         * is completely useless (something like "fopen: failed to open stream")
         * so normal methods of handling errors programmatically
         * like get_last_error() don't work.
+        * @internal
         */
        public function errorHandler( $errno, $errstr ) {
                $n = count( $this->fopenErrors ) + 1;
                $this->fopenErrors += [ "errno$n" => $errno, "errstr$n" => $errstr ];
        }
 
+       /**
+        * @see MWHttpRequest::execute
+        *
+        * @return Status
+        */
        public function execute() {
-
-               parent::execute();
+               $this->prepare();
 
                if ( is_array( $this->postData ) ) {
                        $this->postData = wfArrayToCgi( $this->postData );
@@ -212,7 +216,7 @@ class PhpHttpRequest extends MWHttpRequest {
                        $url = $this->getResponseHeader( "Location" );
 
                        if ( !Http::isValidURI( $url ) ) {
-                               wfDebug( __METHOD__ . ": insecure redirection\n" );
+                               $this->logger->debug( __METHOD__ . ": insecure redirection\n" );
                                break;
                        }
                } while ( true );
@@ -224,16 +228,16 @@ class PhpHttpRequest extends MWHttpRequest {
 
                if ( $fh === false ) {
                        if ( $this->fopenErrors ) {
-                               LoggerFactory::getInstance( 'http' )->warning( __CLASS__
+                               $this->logger->warning( __CLASS__
                                        . ': error opening connection: {errstr1}', $this->fopenErrors );
                        }
                        $this->status->fatal( 'http-request-error' );
-                       return $this->status;
+                       return Status::wrap( $this->status ); // TODO B/C; move this to callers
                }
 
                if ( $result['timed_out'] ) {
                        $this->status->fatal( 'http-timed-out', $this->url );
-                       return $this->status;
+                       return Status::wrap( $this->status ); // TODO B/C; move this to callers
                }
 
                // If everything went OK, or we received some error code
@@ -254,6 +258,6 @@ class PhpHttpRequest extends MWHttpRequest {
                }
                fclose( $fh );
 
-               return $this->status;
+               return Status::wrap( $this->status ); // TODO B/C; move this to callers
        }
 }