Fix Bug#19637 - self-referencing externals will be by default filtered out
[lhc/web/wiklou.git] / includes / filerepo / FileRepo.php
index 44f909f..79fd87e 100644 (file)
@@ -6,6 +6,7 @@
  * @ingroup FileRepo
  */
 abstract class FileRepo {
+       const FILES_ONLY = 1;
        const DELETE_SOURCE = 1;
        const FIND_PRIVATE = 1;
        const FIND_IGNORE_REDIRECT = 2;
@@ -400,6 +401,21 @@ abstract class FileRepo {
         */
        abstract function publishBatch( $triplets, $flags = 0 );
 
+       function fileExists( $file, $flags = 0 ) {
+               $result = $this->fileExistsBatch( array( $file ), $flags );
+               return $result[0];
+       }
+
+       /**
+        * Checks existence of an array of files.
+        *
+        * @param array $files URLs (or paths) of files to check
+        * @param integer $flags Bitwise combination of the following flags:
+        *     self::FILES_ONLY     Mark file as existing only if it is a file (not directory)
+        * @return Either array of files and existence flags, or false
+        */
+       abstract function fileExistsBatch( $files, $flags = 0 );
+
        /**
         * Move a group of files to the deletion archive.
         *
@@ -517,7 +533,8 @@ abstract class FileRepo {
        function cleanupDeletedBatch( $storageKeys ) {}
 
        /**
-        * Checks if there is a redirect named as $title
+        * Checks if there is a redirect named as $title. If there is, return the
+        * title object. If not, return false.
         * STUB
         *
         * @param Title $title Title of image
@@ -528,14 +545,58 @@ abstract class FileRepo {
 
        /**
         * Invalidates image redirect cache related to that image
+        * Doesn't do anything for repositories that don't support image redirects.
+        * 
         * STUB
-        *
         * @param Title $title Title of image
-        */
-       function invalidateImageRedirect( $title ) {
-       }
+        */     
+       function invalidateImageRedirect( $title ) {}
        
+       /**
+        * Get an array or iterator of file objects for files that have a given 
+        * SHA-1 content hash.
+        *
+        * STUB
+        */
        function findBySha1( $hash ) {
                return array();
        }
+       
+       /**
+        * Get the human-readable name of the repo. 
+        * @return string
+        */
+       public function getDisplayName() {
+               // We don't name our own repo, return nothing
+               if ( $this->name == 'local' ) {
+                       return null;
+               }
+               $repoName = wfMsg( 'shared-repo-name-' . $this->name );
+               if ( !wfEmptyMsg( 'shared-repo-name-' . $this->name, $repoName ) ) {
+                       return $repoName;
+               }
+               return wfMsg( 'shared-repo' ); 
+       }
+       
+       /**
+        * Get a key on the primary cache for this repository.
+        * Returns false if the repository's cache is not accessible at this site. 
+        * The parameters are the parts of the key, as for wfMemcKey().
+        *
+        * STUB
+        */
+       function getSharedCacheKey( /*...*/ ) {
+               return false;
+       }
+
+       /**
+        * Get a key for this repo in the local cache domain. These cache keys are 
+        * not shared with remote instances of the repo.
+        * The parameters are the parts of the key, as for wfMemcKey().
+        */
+       function getLocalCacheKey( /*...*/ ) {
+               $args = func_get_args();
+               array_unshift( $args, 'filerepo', $this->getName() );
+               return call_user_func_array( 'wfMemcKey', $args );
+       }
 }