Merge "Drop index oi_name_archive_name on table oldimage"
[lhc/web/wiklou.git] / includes / upload / UploadBase.php
index ea6ef30..733c4ff 100644 (file)
@@ -20,6 +20,7 @@
  * @file
  * @ingroup Upload
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * @defgroup Upload Upload related
@@ -297,7 +298,7 @@ abstract class UploadBase {
         * @param string $srcPath The source path
         * @return string|bool The real path if it was a virtual URL Returns false on failure
         */
-       function getRealPath( $srcPath ) {
+       public function getRealPath( $srcPath ) {
                $repo = RepoGroup::singleton()->getLocalRepo();
                if ( $repo->isVirtualUrl( $srcPath ) ) {
                        /** @todo Just make uploads work with storage paths UploadFromStash
@@ -560,7 +561,7 @@ abstract class UploadBase {
         *
         * @param array $entry
         */
-       function zipEntryCallback( $entry ) {
+       public function zipEntryCallback( $entry ) {
                $names = [ $entry['name'] ];
 
                // If there is a null character, cut off the name at it, because JDK's
@@ -775,7 +776,9 @@ abstract class UploadBase {
                                        User::IGNORE_USER_RIGHTS
                                );
                        }
-                       Hooks::run( 'UploadComplete', [ &$this ] );
+                       // Avoid PHP 7.1 warning of passing $this by reference
+                       $uploadBase = $this;
+                       Hooks::run( 'UploadComplete', [ &$uploadBase ] );
 
                        $this->postProcessUpload();
                }
@@ -893,7 +896,7 @@ abstract class UploadBase {
                        return $this->mTitle;
                }
 
-               // Windows may be broken with special characters, see bug 1780
+               // Windows may be broken with special characters, see T3780
                if ( !preg_match( '/^[\x0-\x7f]*$/', $nt->getText() )
                        && !RepoGroup::singleton()->getLocalRepo()->backendSupportsUnicodePaths()
                ) {
@@ -1207,7 +1210,7 @@ abstract class UploadBase {
                }
 
                // Some browsers will interpret obscure xml encodings as UTF-8, while
-               // PHP/expat will interpret the given encoding in the xml declaration (bug 47304)
+               // PHP/expat will interpret the given encoding in the xml declaration (T49304)
                if ( $extension == 'svg' || strpos( $mime, 'image/svg' ) === 0 ) {
                        if ( self::checkXMLEncodingMissmatch( $file ) ) {
                                return true;
@@ -1359,8 +1362,8 @@ abstract class UploadBase {
                        [ 'processing_instruction_handler' => 'UploadBase::checkSvgPICallback' ]
                );
                if ( $check->wellFormed !== true ) {
-                       // Invalid xml (bug 58553)
-                       // But only when non-partial (bug 65724)
+                       // Invalid xml (T60553)
+                       // But only when non-partial (T67724)
                        return $partial ? false : [ 'uploadinvalidxml' ];
                } elseif ( $check->filterMatch ) {
                        if ( $this->mSVGNSError ) {
@@ -1380,7 +1383,7 @@ abstract class UploadBase {
         * @return bool (true if the filter identified something bad)
         */
        public static function checkSvgPICallback( $target, $data ) {
-               // Don't allow external stylesheets (bug 57550)
+               // Don't allow external stylesheets (T59550)
                if ( preg_match( '/xml-stylesheet/i', $target ) ) {
                        return [ 'upload-scripted-pi-callback' ];
                }
@@ -1399,7 +1402,7 @@ abstract class UploadBase {
                list( $namespace, $strippedElement ) = $this->splitXmlNamespace( $element );
 
                // We specifically don't include:
-               // http://www.w3.org/1999/xhtml (bug 60771)
+               // http://www.w3.org/1999/xhtml (T62771)
                static $validNamespaces = [
                        '',
                        'adobe:ns:meta/',
@@ -1438,6 +1441,7 @@ abstract class UploadBase {
                        'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
                        'http://www.w3.org/2000/svg',
                        'http://www.w3.org/tr/rec-rdf-syntax/',
+                       'http://www.w3.org/2000/01/rdf-schema#',
                ];
 
                // Inkscape mangles namespace definitions created by Adobe Illustrator.
@@ -2080,7 +2084,7 @@ abstract class UploadBase {
        public static function getSessionStatus( User $user, $statusKey ) {
                $key = wfMemcKey( 'uploadstatus', $user->getId() ?: md5( $user->getName() ), $statusKey );
 
-               return ObjectCache::getMainStashInstance()->get( $key );
+               return MediaWikiServices::getInstance()->getMainObjectStash()->get( $key );
        }
 
        /**
@@ -2096,7 +2100,7 @@ abstract class UploadBase {
        public static function setSessionStatus( User $user, $statusKey, $value ) {
                $key = wfMemcKey( 'uploadstatus', $user->getId() ?: md5( $user->getName() ), $statusKey );
 
-               $cache = ObjectCache::getMainStashInstance();
+               $cache = MediaWikiServices::getInstance()->getMainObjectStash();
                if ( $value === false ) {
                        $cache->delete( $key );
                } else {