Merge "Remove unused 'XMPGetInfo' and 'XMPGetResults' hooks"
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index df85f9c..eb50a12 100644 (file)
@@ -47,7 +47,7 @@
  *
  * @ingroup FileAbstraction
  */
-abstract class File {
+abstract class File implements IDBAccessObject {
        // Bitfield values akin to the Revision deletion constants
        const DELETED_FILE = 1;
        const DELETED_COMMENT = 2;
@@ -163,7 +163,8 @@ abstract class File {
         * @param FileRepo|bool $repo
         */
        function __construct( $title, $repo ) {
-               if ( $title !== false ) { // subclasses may not use MW titles
+               // Some subclasses do not use $title, but set name/title some other way
+               if ( $title !== false ) {
                        $title = self::normalizeTitle( $title, 'exception' );
                }
                $this->title = $title;
@@ -836,6 +837,18 @@ abstract class File {
                return false;
        }
 
+       /**
+        * Load any lazy-loaded file object fields from source
+        *
+        * This is only useful when setting $flags
+        *
+        * Overridden by LocalFile to actually query the DB
+        *
+        * @param integer $flags Bitfield of File::READ_* constants
+        */
+       public function load( $flags = 0 ) {
+       }
+
        /**
         * Returns true if file exists in the repository.
         *
@@ -1765,14 +1778,15 @@ abstract class File {
        }
 
        /**
+        * @param bool|IContextSource $context Context to use (optional)
         * @return bool
         */
-       function formatMetadata() {
+       function formatMetadata( $context = false ) {
                if ( !$this->getHandler() ) {
                        return false;
                }
 
-               return $this->getHandler()->formatMetadata( $this, $this->getMetadata() );
+               return $this->getHandler()->formatMetadata( $this, $context );
        }
 
        /**
@@ -2008,7 +2022,7 @@ abstract class File {
                                wfDebug( "miss\n" );
                        }
                        wfDebug( "Fetching shared description from $renderUrl\n" );
-                       $res = Http::get( $renderUrl );
+                       $res = Http::get( $renderUrl, array(), __METHOD__ );
                        if ( $res && $this->repo->descriptionCacheExpiry > 0 ) {
                                $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
                        }
@@ -2046,6 +2060,17 @@ abstract class File {
                return $this->repo->getFileTimestamp( $this->getPath() );
        }
 
+       /**
+        * Returns the timestamp (in TS_MW format) of the last change of the description page.
+        * Returns false if the file does not have a description page, or retrieving the timestamp
+        * would be expensive.
+        * @since 1.25
+        * @return string|bool
+        */
+       public function getDescriptionTouched() {
+               return false;
+       }
+
        /**
         * Get the SHA-1 base 36 hash of the file
         *