X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fupload%2FUploadStash.php;h=e55ab1fbb78e4865278986c131a9ad74603d586f;hp=c2ab899789bed7aab90d56519d9aab72affe8fed;hb=f80e50f318a350c4486d272b1bc1bb5c22715a7c;hpb=716814a5d501efcc99b09fbb7e26caaf9a395d26 diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index c2ab899789..e55ab1fbb7 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -18,7 +18,6 @@ * http://www.gnu.org/copyleft/gpl.html * * @file - * @ingroup Upload */ /** @@ -53,7 +52,7 @@ */ class UploadStash { // Format of the key for files -- has to be suitable as a filename itself (e.g. ab12cd34ef.jpg) - const KEY_FORMAT_REGEX = '/^[\w-\.]+\.\w*$/'; + const KEY_FORMAT_REGEX = '/^[\w\-\.]+\.\w*$/'; const MAX_US_PROPS_SIZE = 65535; /** @@ -218,7 +217,7 @@ class UploadStash { ); } - $mwProps = new MWFileProps( MimeMagic::singleton() ); + $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() ); $fileProps = $mwProps->getPropsFromPath( $path, true ); wfDebug( __METHOD__ . " stashing file at '$path'\n" ); @@ -490,9 +489,9 @@ class UploadStash { $extension = $n ? substr( $path, $n + 1 ) : ''; } else { // If not, assume that it should be related to the MIME type of the original file. - $magic = MimeMagic::singleton(); + $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer(); $mimeType = $magic->guessMimeType( $path ); - $extensions = explode( ' ', MimeMagic::singleton()->getExtensionsForType( $mimeType ) ); + $extensions = explode( ' ', $magic->getExtensionsForType( $mimeType ) ); if ( count( $extensions ) ) { $extension = $extensions[0]; } @@ -576,6 +575,9 @@ class UploadStash { } } +/** + * @ingroup Upload + */ class UploadStashFile extends UnregisteredLocalFile { private $fileKey; private $urlName; @@ -765,6 +767,9 @@ class UploadStashFile extends UnregisteredLocalFile { } } +/** + * @ingroup Upload + */ class UploadStashException extends MWException implements ILocalizedException { /** @var string|array|MessageSpecifier */ protected $messageSpec; @@ -788,23 +793,44 @@ class UploadStashException extends MWException implements ILocalizedException { } } +/** + * @ingroup Upload + */ class UploadStashFileNotFoundException extends UploadStashException { } +/** + * @ingroup Upload + */ class UploadStashBadPathException extends UploadStashException { } +/** + * @ingroup Upload + */ class UploadStashFileException extends UploadStashException { } +/** + * @ingroup Upload + */ class UploadStashZeroLengthFileException extends UploadStashException { } +/** + * @ingroup Upload + */ class UploadStashNotLoggedInException extends UploadStashException { } +/** + * @ingroup Upload + */ class UploadStashWrongOwnerException extends UploadStashException { } +/** + * @ingroup Upload + */ class UploadStashNoSuchKeyException extends UploadStashException { }