* Declaration of Image::newFromTitle() should be compatible with that of LocalFile::newFromTitle() : Moved Image class to Image.php, will only be loaded when an old extension need it.
* Declaration of OldLocalFile::newFromTitle() should be compatible with that of LocalFile::newFromTitle() : Added an unsed param to LocalFile::newFromTitle() with a null default value, also added the null default value to OldLocalFile::newFromTitle() but that function will throw an Exception if that value isn't modified (even if these functions should not be called by extensions).
Pass $suffix parameter to File::getArchiveRel() in File::getArchivePath()
'ForeignDBRepo' => 'includes/filerepo/ForeignDBRepo.php',
'ForeignDBViaLBRepo' => 'includes/filerepo/ForeignDBViaLBRepo.php',
'FSRepo' => 'includes/filerepo/FSRepo.php',
- 'Image' => 'includes/filerepo/LocalFile.php',
+ 'Image' => 'includes/filerepo/Image.php',
'LocalFileDeleteBatch' => 'includes/filerepo/LocalFile.php',
'LocalFile' => 'includes/filerepo/LocalFile.php',
'LocalFileRestoreBatch' => 'includes/filerepo/LocalFile.php',
/** Get the path of the archive directory, or a particular file if $suffix is specified */
function getArchivePath( $suffix = false ) {
- return $this->repo->getZonePath('public') . '/' . $this->getArchiveRel();
+ return $this->repo->getZonePath('public') . '/' . $this->getArchiveRel( $suffix );
}
/** Get the path of the thumbnail directory, or a particular file if $suffix is specified */
--- /dev/null
+<?php
+
+/**
+ * Backwards compatibility class
+ * @deprecated
+ */
+class Image extends LocalFile {
+ function __construct( $title ) {
+ $repo = RepoGroup::singleton()->getLocalRepo();
+ parent::__construct( $title, $repo );
+ }
+
+ /**
+ * Wrapper for wfFindFile(), for backwards-compatibility only
+ * Do not use in core code.
+ * @deprecated
+ */
+ static function newFromTitle( $title, $time = false ) {
+ $img = wfFindFile( $title, $time );
+ if ( !$img ) {
+ $img = wfLocalFile( $title );
+ }
+ return $img;
+ }
+
+ /**
+ * Wrapper for wfFindFile(), for backwards-compatibility only.
+ * Do not use in core code.
+ *
+ * @param string $name name of the image, used to create a title object using Title::makeTitleSafe
+ * @return image object or null if invalid title
+ * @deprecated
+ */
+ static function newFromName( $name ) {
+ $title = Title::makeTitleSafe( NS_IMAGE, $name );
+ if ( is_object( $title ) ) {
+ $img = wfFindFile( $title );
+ if ( !$img ) {
+ $img = wfLocalFile( $title );
+ }
+ return $img;
+ } else {
+ return NULL;
+ }
+ }
+
+ /**
+ * Return the URL of an image, provided its name.
+ *
+ * Backwards-compatibility for extensions.
+ * Note that fromSharedDirectory will only use the shared path for files
+ * that actually exist there now, and will return local paths otherwise.
+ *
+ * @param string $name Name of the image, without the leading "Image:"
+ * @param boolean $fromSharedDirectory Should this be in $wgSharedUploadPath?
+ * @return string URL of $name image
+ * @deprecated
+ */
+ static function imageUrl( $name, $fromSharedDirectory = false ) {
+ $image = null;
+ if( $fromSharedDirectory ) {
+ $image = wfFindFile( $name );
+ }
+ if( !$image ) {
+ $image = wfLocalFile( $name );
+ }
+ return $image->getUrl();
+ }
+}
\ No newline at end of file
/**
* Create a LocalFile from a title
* Do not call this except from inside a repo class.
+ *
+ * Note: $unused param is only here to avoid an E_STRICT
*/
- static function newFromTitle( $title, $repo ) {
+ static function newFromTitle( $title, $repo, $unused = null ) {
return new self( $title, $repo );
}
#------------------------------------------------------------------------------
-/**
- * Backwards compatibility class
- */
-class Image extends LocalFile {
- function __construct( $title ) {
- $repo = RepoGroup::singleton()->getLocalRepo();
- parent::__construct( $title, $repo );
- }
-
- /**
- * Wrapper for wfFindFile(), for backwards-compatibility only
- * Do not use in core code.
- * @deprecated
- */
- static function newFromTitle( $title, $time = false ) {
- $img = wfFindFile( $title, $time );
- if ( !$img ) {
- $img = wfLocalFile( $title );
- }
- return $img;
- }
-
- /**
- * Wrapper for wfFindFile(), for backwards-compatibility only.
- * Do not use in core code.
- *
- * @param string $name name of the image, used to create a title object using Title::makeTitleSafe
- * @return image object or null if invalid title
- * @deprecated
- */
- static function newFromName( $name ) {
- $title = Title::makeTitleSafe( NS_IMAGE, $name );
- if ( is_object( $title ) ) {
- $img = wfFindFile( $title );
- if ( !$img ) {
- $img = wfLocalFile( $title );
- }
- return $img;
- } else {
- return NULL;
- }
- }
-
- /**
- * Return the URL of an image, provided its name.
- *
- * Backwards-compatibility for extensions.
- * Note that fromSharedDirectory will only use the shared path for files
- * that actually exist there now, and will return local paths otherwise.
- *
- * @param string $name Name of the image, without the leading "Image:"
- * @param boolean $fromSharedDirectory Should this be in $wgSharedUploadPath?
- * @return string URL of $name image
- * @deprecated
- */
- static function imageUrl( $name, $fromSharedDirectory = false ) {
- $image = null;
- if( $fromSharedDirectory ) {
- $image = wfFindFile( $name );
- }
- if( !$image ) {
- $image = wfLocalFile( $name );
- }
- return $image->getUrl();
- }
-}
-
-#------------------------------------------------------------------------------
-
/**
* Helper class for file deletion
*/
const CACHE_VERSION = 1;
const MAX_CACHE_ROWS = 20;
- static function newFromTitle( $title, $repo, $time ) {
+ static function newFromTitle( $title, $repo, $time = null ) {
+ # The null default value is only here to avoid an E_STRICT
+ if( $time === null )
+ throw new MWException( __METHOD__.' got null for $time parameter' );
return new self( $title, $repo, $time, null );
}