when getting file (img) properties, suppress whines that it's not xml
[lhc/web/wiklou.git] / includes / libs / mime / MimeAnalyzer.php
index 413fb2a..f493769 100644 (file)
@@ -755,7 +755,9 @@ EOT;
                /**
                 * look for XML formats (XHTML and SVG)
                 */
+               Wikimedia\suppressWarnings();
                $xml = new XmlTypeCheck( $file );
+               Wikimedia\restoreWarnings();
                if ( $xml->wellFormed ) {
                        $xmlTypes = $this->xmlTypes;
                        return $xmlTypes[$xml->getRootElement()] ?? 'application/xml';
@@ -806,9 +808,7 @@ EOT;
                if ( $eocdrPos !== false ) {
                        $this->logger->info( __METHOD__ . ": ZIP signature present in $file\n" );
                        // Check if it really is a ZIP file, make sure the EOCDR is at the end (T40432)
-                       // FIXME: unpack()'s third argument was added in PHP 7.1
-                       // @phan-suppress-next-line PhanParamTooManyInternal
-                       $commentLength = unpack( "n", $tail, $eocdrPos + 20 )[0];
+                       $commentLength = unpack( "n", substr( $tail, $eocdrPos + 20 ) )[0];
                        if ( $eocdrPos + 22 + $commentLength !== strlen( $tail ) ) {
                                $this->logger->info( __METHOD__ . ": ZIP EOCDR not at end. Not a ZIP file." );
                        } else {
@@ -851,7 +851,7 @@ EOT;
                $callback = $this->guessCallback;
                if ( $callback ) {
                        $callback( $this, $head, $tail, $file, $mime /* by reference */ );
-               };
+               }
 
                return $mime;
        }