Ugly hack to fix two strict standarts errors:
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 5 Apr 2008 12:26:10 +0000 (12:26 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 5 Apr 2008 12:26:10 +0000 (12:26 +0000)
* 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()

includes/AutoLoader.php
includes/filerepo/File.php
includes/filerepo/Image.php [new file with mode: 0644]
includes/filerepo/LocalFile.php
includes/filerepo/OldLocalFile.php

index ffc1351..ebf166c 100644 (file)
@@ -297,7 +297,7 @@ function __autoload($className) {
                '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',
index 72eacc4..4b517a2 100644 (file)
@@ -723,7 +723,7 @@ abstract class File {
 
        /** 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 */
diff --git a/includes/filerepo/Image.php b/includes/filerepo/Image.php
new file mode 100644 (file)
index 0000000..9ab750c
--- /dev/null
@@ -0,0 +1,69 @@
+<?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
index 871756a..f3afc74 100644 (file)
@@ -56,8 +56,10 @@ class LocalFile extends 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 );
        }
 
@@ -1090,75 +1092,6 @@ class LocalFile extends File
 
 #------------------------------------------------------------------------------
 
-/**
- * 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
  */
index 581bce4..4906e79 100644 (file)
@@ -11,7 +11,10 @@ class OldLocalFile extends LocalFile {
        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 );
        }