From 6aaaa070f33552939e6c2b698ddbbadd22d1f4bd Mon Sep 17 00:00:00 2001 From: Reedy Date: Fri, 21 Sep 2018 02:40:59 +0100 Subject: [PATCH] Remove MimeMagic Deprecated since 1.28 Change-Id: I793deb8669e353525464ccd840801e5015c545c8 --- RELEASE-NOTES-1.32 | 2 ++ autoload.php | 1 - docs/hooks.txt | 6 ++-- includes/DefaultSettings.php | 4 +-- includes/MimeMagic.php | 43 ---------------------------- includes/ServiceWiring.php | 3 +- includes/filerepo/file/LocalFile.php | 2 +- includes/utils/MWFileProps.php | 2 +- 8 files changed, 10 insertions(+), 53 deletions(-) delete mode 100644 includes/MimeMagic.php diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 7a3cb1508e..cfe90a016c 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -316,6 +316,8 @@ because of Phabricator reports. behaviour which has been deprecated since 1.24. * LBFactory, deprecated since 1.28, has been removed. Instead, use Wikimedia\Rdbms\LBFactory. +* The MimeMagic class, deprecated since 1.28 has been removed. Get a + MimeAnalyzer instance from MediaWikiServices instead. === Deprecations in 1.32 === * HTMLForm::setSubmitProgressive() is deprecated. No need to call it. Submit diff --git a/autoload.php b/autoload.php index 96a7dc3036..f63ccb5055 100644 --- a/autoload.php +++ b/autoload.php @@ -950,7 +950,6 @@ $wgAutoloadLocalClasses = [ 'MigrateFileRepoLayout' => __DIR__ . '/maintenance/migrateFileRepoLayout.php', 'MigrateUserGroup' => __DIR__ . '/maintenance/migrateUserGroup.php', 'MimeAnalyzer' => __DIR__ . '/includes/libs/mime/MimeAnalyzer.php', - 'MimeMagic' => __DIR__ . '/includes/MimeMagic.php', 'MinifyScript' => __DIR__ . '/maintenance/minify.php', 'MostcategoriesPage' => __DIR__ . '/includes/specials/SpecialMostcategories.php', 'MostimagesPage' => __DIR__ . '/includes/specials/SpecialMostimages.php', diff --git a/docs/hooks.txt b/docs/hooks.txt index 82238142b0..063bbe5ba0 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2353,7 +2353,7 @@ $title: title of the message (string) $code: code (string) denoting the language to try. 'MimeMagicGuessFromContent': Allows MW extensions guess the MIME by content. -$mimeMagic: Instance of MimeMagic. +$mimeMagic: Instance of MimeAnalyzer. &$head: First 1024 bytes of the file in a string (in - Do not alter!). &$tail: More or equal than last 65558 bytes of the file in a string (in - Do not alter!). @@ -2362,7 +2362,7 @@ $file: File path. 'MimeMagicImproveFromExtension': Allows MW extensions to further improve the MIME type detected by considering the file extension. -$mimeMagic: Instance of MimeMagic. +$mimeMagic: Instance of MimeAnalyzer. $ext: File extension. &$mime: MIME type (in/out). @@ -2370,7 +2370,7 @@ $ext: File extension. and the list mapping MIME types to file extensions. As an extension author, you are encouraged to submit patches to MediaWiki's core to add new MIME types to mime.types. -$mimeMagic: Instance of MimeMagic. +$mimeMagic: Instance of MimeAnalyzer. Use $mimeMagic->addExtraInfo( $stringOfInfo ); for adding new MIME info to the list. Use $mimeMagic->addExtraTypes( $stringOfTypes ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d335dccac0..3ef524366d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1380,14 +1380,14 @@ $wgAntivirusRequired = true; $wgVerifyMimeType = true; /** - * Sets the MIME type definition file to use by MimeMagic.php. + * Sets the MIME type definition file to use by includes/libs/mime/MimeAnalyzer.php. * Set to null, to use built-in defaults only. * example: $wgMimeTypeFile = '/etc/mime.types'; */ $wgMimeTypeFile = 'includes/mime.types'; /** - * Sets the MIME type info file to use by MimeMagic.php. + * Sets the MIME type info file to use by includes/libs/mime/MimeAnalyzer.php. * Set to null, to use built-in defaults only. */ $wgMimeInfoFile = 'includes/mime.info'; diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php deleted file mode 100644 index 6152d2262f..0000000000 --- a/includes/MimeMagic.php +++ /dev/null @@ -1,43 +0,0 @@ -getMimeAnalyzer(); - Assert::postcondition( - $instance instanceof MimeMagic, - __METHOD__ . ' should return an instance of ' . self::class - ); - return $instance; - } -} diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index b8bd5d2270..cf2def22cc 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -321,8 +321,7 @@ return [ }; } - // XXX: MimeMagic::singleton currently requires this service to return an instance of MimeMagic - return new MimeMagic( $params ); + return new MimeAnalyzer( $params ); }, 'NameTableStoreFactory' => function ( MediaWikiServices $services ) : NameTableStoreFactory { diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index fa6e180ee1..b6c249b4a2 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -63,7 +63,7 @@ class LocalFile extends File { /** @var string MEDIATYPE_xxx (bitmap, drawing, audio...) */ protected $media_type; - /** @var string MIME type, determined by MimeMagic::guessMimeType */ + /** @var string MIME type, determined by MimeAnalyzer::guessMimeType */ protected $mime; /** @var int Size in bytes (loadFromXxx) */ diff --git a/includes/utils/MWFileProps.php b/includes/utils/MWFileProps.php index 9d05c6ab17..a20435e17d 100644 --- a/includes/utils/MWFileProps.php +++ b/includes/utils/MWFileProps.php @@ -26,7 +26,7 @@ * @since 1.28 */ class MWFileProps { - /** @var MimeMagic */ + /** @var MimeAnalyzer */ private $magic; /** -- 2.20.1