Merge "Improve docs for Title::getInternalURL/getCanonicalURL"
[lhc/web/wiklou.git] / includes / upload / UploadBase.php
index a579b69..9e92e78 100644 (file)
@@ -296,7 +296,7 @@ abstract class UploadBase {
         */
        public function getRealPath( $srcPath ) {
                $repo = RepoGroup::singleton()->getLocalRepo();
-               if ( $repo->isVirtualUrl( $srcPath ) ) {
+               if ( FileRepo::isVirtualUrl( $srcPath ) ) {
                        /** @todo Just make uploads work with storage paths UploadFromStash
                         *  loads files via virtual URLs.
                         */
@@ -947,8 +947,8 @@ abstract class UploadBase {
                 */
                list( $partname, $ext ) = $this->splitExtensions( $this->mFilteredName );
 
-               if ( count( $ext ) ) {
-                       $this->mFinalExtension = trim( $ext[count( $ext ) - 1] );
+               if ( $ext !== [] ) {
+                       $this->mFinalExtension = trim( end( $ext ) );
                } else {
                        $this->mFinalExtension = '';
 
@@ -1078,10 +1078,8 @@ abstract class UploadBase {
                $props = $this->mFileProps;
                $error = null;
                Hooks::run( 'UploadStashFile', [ $this, $user, $props, &$error ] );
-               if ( $error ) {
-                       if ( !is_array( $error ) ) {
-                               $error = [ $error ];
-                       }
+               if ( $error && !is_array( $error ) ) {
+                       $error = [ $error ];
                }
                return $error;
        }
@@ -1169,7 +1167,7 @@ abstract class UploadBase {
         * scripts, so the blacklist needs to check them all.
         *
         * @param string $filename
-        * @return array
+        * @return array [ string, string[] ]
         */
        public static function splitExtensions( $filename ) {
                $bits = explode( '.', $filename );
@@ -1194,8 +1192,8 @@ abstract class UploadBase {
         * Perform case-insensitive match against a list of file extensions.
         * Returns an array of matching extensions.
         *
-        * @param array $ext
-        * @param array $list
+        * @param string[] $ext
+        * @param string[] $list
         * @return bool
         */
        public static function checkFileExtensionList( $ext, $list ) {
@@ -1916,10 +1914,8 @@ abstract class UploadBase {
                                $output = true; # if there's no output, return true
                        } elseif ( $msgPattern ) {
                                $groups = [];
-                               if ( preg_match( $msgPattern, $output, $groups ) ) {
-                                       if ( $groups[1] ) {
-                                               $output = $groups[1];
-                                       }
+                               if ( preg_match( $msgPattern, $output, $groups ) && $groups[1] ) {
+                                       $output = $groups[1];
                                }
                        }