PleaseStand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/147382

Change subject: Remove dead mime_content_type() code paths
......................................................................

Remove dead mime_content_type() code paths

Since PHP 5.3, mime_content_type() is implemented as part of PHP's
fileinfo extension and thus is deprecated in favor of the newer
alternatives provided by that extension (already in use).

Also updated a comment in DefaultSettings.php that mentioned the
function. Did not modify lessc.inc.php, a third-party library
maintained separately from MediaWiki.

Change-Id: Ic4a0873989ddb634ec9a05c3340941a9ba3f5ec5
---
M includes/DefaultSettings.php
M includes/MimeMagic.php
M includes/libs/CSSMin.php
3 files changed, 7 insertions(+), 39 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/82/147382/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 7c81294..24b4501 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -1154,7 +1154,7 @@
  * Sets an external mime detector program. The command must print only
  * the mime type to standard output.
  * The name of the file to process will be appended to the command given here.
- * If not set or NULL, mime_content_type will be used if available.
+ * If not set or NULL, PHP's fileinfo extension will be used if available.
  *
  * @par Example:
  * @code
diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php
index b4d3ab1..369235c 100644
--- a/includes/MimeMagic.php
+++ b/includes/MimeMagic.php
@@ -898,9 +898,9 @@
        /**
         * Internal mime type detection. Detection is done using an external
         * program, if $wgMimeDetectorCommand is set. Otherwise, the fileinfo
-        * extension and mime_content_type are tried (in this order), if they
-        * are available. If the detections fails and $ext is not false, the 
mime
-        * type is guessed from the file extension, using 
guessTypesForExtension.
+        * extension is tried if it is available. If detection fails and $ext
+        * is not false, the mime type is guessed from the file extension,
+        * using guessTypesForExtension.
         *
         * If the mime type is still unknown, getimagesize is used to detect the
         * mime type if the file is an image. If no mime type can be determined,
@@ -927,18 +927,7 @@
                        $args = wfEscapeShellArg( $file );
                        $m = wfShellExec( "$wgMimeDetectorCommand $args" );
                } elseif ( function_exists( "finfo_open" ) && function_exists( 
"finfo_file" ) ) {
-
-                       # This required the fileinfo extension by PECL,
-                       # see http://pecl.php.net/package/fileinfo
-                       # This must be compiled into PHP
-                       #
-                       # finfo is the official replacement for the deprecated
-                       # mime_content_type function, see below.
-                       #
-                       # If you may need to load the fileinfo extension at 
runtime, set
-                       # $wgLoadFileinfoExtension in LocalSettings.php
-
-                       $mime_magic_resource = finfo_open( FILEINFO_MIME ); /* 
return mime type ala mimetype extension */
+                       $mime_magic_resource = finfo_open( FILEINFO_MIME );
 
                        if ( $mime_magic_resource ) {
                                $m = finfo_file( $mime_magic_resource, $file );
@@ -946,21 +935,6 @@
                        } else {
                                wfDebug( __METHOD__ . ": finfo_open failed on " 
. FILEINFO_MIME . "!\n" );
                        }
-               } elseif ( function_exists( "mime_content_type" ) ) {
-
-                       # NOTE: this function is available since PHP 4.3.0, but 
only if
-                       # PHP was compiled with --with-mime-magic or, before 
4.3.2, with
-                       # --enable-mime-magic.
-                       #
-                       # On Windows, you must set mime_magic.magicfile in 
php.ini to point
-                       # to the mime.magic file bundled with PHP; sometimes, 
this may even
-                       # be needed under *nix.
-                       #
-                       # Also note that this has been DEPRECATED in favor of 
the fileinfo
-                       # extension by PECL, see above.
-                       # See http://www.php.net/manual/en/ref.mime-magic.php 
for details.
-
-                       $m = mime_content_type( $file );
                } else {
                        wfDebug( __METHOD__ . ": no magic mime detector 
found!\n" );
                }
diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php
index 4885ae6..fa457d4 100644
--- a/includes/libs/CSSMin.php
+++ b/includes/libs/CSSMin.php
@@ -135,22 +135,16 @@
         */
        public static function getMimeType( $file ) {
                $realpath = realpath( $file );
-               // Try a couple of different ways to get the mime-type of a 
file, in order of
-               // preference
                if (
                        $realpath
                        && function_exists( 'finfo_file' )
                        && function_exists( 'finfo_open' )
                        && defined( 'FILEINFO_MIME_TYPE' )
                ) {
-                       // As of PHP 5.3, this is how you get the mime-type of 
a file; it uses the Fileinfo
-                       // PECL extension
+                       // Can use PHP's fileinfo extension
                        return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), 
$realpath );
-               } elseif ( function_exists( 'mime_content_type' ) ) {
-                       // Before this was deprecated in PHP 5.3, this was how 
you got the mime-type of a file
-                       return mime_content_type( $file );
                } else {
-                       // Worst-case scenario has happened, use the file 
extension to infer the mime-type
+                       // Have to infer the mime-type from the file extension
                        $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION 
) );
                        if ( isset( self::$mimeTypes[$ext] ) ) {
                                return self::$mimeTypes[$ext];

-- 
To view, visit https://gerrit.wikimedia.org/r/147382
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic4a0873989ddb634ec9a05c3340941a9ba3f5ec5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <pleasest...@live.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to