Merge "Log entries can be rendered with parentheses in HTML"
[lhc/web/wiklou.git] / includes / import / ImportStreamSource.php
index 94a2b93..81e414e 100644 (file)
@@ -30,6 +30,12 @@ use MediaWiki\MediaWikiServices;
  * @ingroup SpecialPage
  */
 class ImportStreamSource implements ImportSource {
+       /** @var resource */
+       private $mHandle;
+
+       /**
+        * @param resource $handle
+        */
        function __construct( $handle ) {
                $this->mHandle = $handle;
        }
@@ -53,9 +59,9 @@ class ImportStreamSource implements ImportSource {
         * @return Status
         */
        static function newFromFile( $filename ) {
-               MediaWiki\suppressWarnings();
+               Wikimedia\suppressWarnings();
                $file = fopen( $filename, 'rt' );
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
                if ( !$file ) {
                        return Status::newFatal( "importcantopen" );
                }
@@ -74,20 +80,21 @@ class ImportStreamSource implements ImportSource {
                }
                if ( !empty( $upload['error'] ) ) {
                        switch ( $upload['error'] ) {
-                               case 1:
-                                       # The uploaded file exceeds the upload_max_filesize directive in php.ini.
+                               case UPLOAD_ERR_INI_SIZE:
+                                       // The uploaded file exceeds the upload_max_filesize directive in php.ini.
                                        return Status::newFatal( 'importuploaderrorsize' );
-                               case 2:
-                                       # The uploaded file exceeds the MAX_FILE_SIZE directive that
-                                       # was specified in the HTML form.
+                               case UPLOAD_ERR_FORM_SIZE:
+                                       // The uploaded file exceeds the MAX_FILE_SIZE directive that
+                                       // was specified in the HTML form.
+                                       // FIXME This is probably never used since that directive was removed in 8e91c520?
                                        return Status::newFatal( 'importuploaderrorsize' );
-                               case 3:
-                                       # The uploaded file was only partially uploaded
+                               case UPLOAD_ERR_PARTIAL:
+                                       // The uploaded file was only partially uploaded
                                        return Status::newFatal( 'importuploaderrorpartial' );
-                               case 6:
-                                       # Missing a temporary folder.
+                               case UPLOAD_ERR_NO_TMP_DIR:
+                                       // Missing a temporary folder.
                                        return Status::newFatal( 'importuploaderrortemp' );
-                               # case else: # Currently impossible
+                               // Other error codes get the generic 'importnofile' error message below
                        }
 
                }
@@ -111,7 +118,7 @@ class ImportStreamSource implements ImportSource {
                # quicker and sorts out user-agent problems which might
                # otherwise prevent importing from large sites, such
                # as the Wikimedia cluster, etc.
-               $data = Http::request(
+               $data = MediaWikiServices::getInstance()->getHttpRequestFactory()->request(
                        $method,
                        $url,
                        [