Replace call_user_func_array(), part 2
[lhc/web/wiklou.git] / includes / upload / UploadBase.php
index f5c8ee0..5352d95 100644 (file)
@@ -854,7 +854,7 @@ abstract class UploadBase {
                        if ( !is_array( $error ) ) {
                                $error = [ $error ];
                        }
-                       return call_user_func_array( 'Status::newFatal', $error );
+                       return Status::newFatal( ...$error );
                }
 
                $status = $this->getLocalFile()->upload(
@@ -1063,7 +1063,7 @@ abstract class UploadBase {
                if ( !$isPartial ) {
                        $error = $this->runUploadStashFileHook( $user );
                        if ( $error ) {
-                               return call_user_func_array( 'Status::newFatal', $error );
+                               return Status::newFatal( ...$error );
                        }
                }
                try {
@@ -1397,7 +1397,7 @@ abstract class UploadBase {
         */
        public static function checkXMLEncodingMissmatch( $file ) {
                global $wgSVGMetadataCutoff;
-               $contents = file_get_contents( $file, false, null, -1, $wgSVGMetadataCutoff );
+               $contents = file_get_contents( $file, false, null, 0, $wgSVGMetadataCutoff );
                $encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
 
                if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
@@ -1425,9 +1425,9 @@ abstract class UploadBase {
                // detect the encoding in case is specifies an encoding not whitelisted in self::$safeXmlEncodings
                $attemptEncodings = [ 'UTF-16', 'UTF-16BE', 'UTF-32', 'UTF-32BE' ];
                foreach ( $attemptEncodings as $encoding ) {
-                       MediaWiki\suppressWarnings();
+                       Wikimedia\suppressWarnings();
                        $str = iconv( $encoding, 'UTF-8', $contents );
-                       MediaWiki\restoreWarnings();
+                       Wikimedia\restoreWarnings();
                        if ( $str != '' && preg_match( "!<\?xml\b(.*?)\?>!si", $str, $matches ) ) {
                                if ( preg_match( $encodingRegex, $matches[1], $encMatch )
                                        && !in_array( strtoupper( $encMatch[1] ), self::$safeXmlEncodings )
@@ -1663,9 +1663,8 @@ abstract class UploadBase {
                        # image/svg, text/xml, application/xml, and text/html, which can contain scripts
                        if ( $stripped == 'href' && strncasecmp( 'data:', $value, 5 ) === 0 ) {
                                // rfc2397 parameters. This is only slightly slower than (;[\w;]+)*.
-                               // @codingStandardsIgnoreStart Generic.Files.LineLength
+                               // phpcs:ignore Generic.Files.LineLength
                                $parameters = '(?>;[a-zA-Z0-9\!#$&\'*+.^_`{|}~-]+=(?>[a-zA-Z0-9\!#$&\'*+.^_`{|}~-]+|"(?>[\0-\x0c\x0e-\x21\x23-\x5b\x5d-\x7f]+|\\\\[\0-\x7f])*"))*(?:;base64)?';
-                               // @codingStandardsIgnoreEnd
 
                                if ( !preg_match( "!^data:\s*image/(gif|jpeg|jpg|png)$parameters,!i", $value ) ) {
                                        wfDebug( __METHOD__ . ": Found href to unwhitelisted data: uri "
@@ -1865,8 +1864,7 @@ abstract class UploadBase {
                # look up scanner configuration
                $command = $wgAntivirusSetup[$wgAntivirus]['command'];
                $exitCodeMap = $wgAntivirusSetup[$wgAntivirus]['codemap'];
-               $msgPattern = isset( $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ) ?
-                       $wgAntivirusSetup[$wgAntivirus]['messagepattern'] : null;
+               $msgPattern = $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ?? null;
 
                if ( strpos( $command, "%f" ) === false ) {
                        # simple pattern: append file to scan