Removed old HTMLCacheUpdateJob b/c code
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 30e31c3..699c915 100644 (file)
@@ -109,6 +109,9 @@ class LocalFile extends File {
        /** @var string Description of current revision of the file */
        private $description;
 
+       /** @var string TS_MW timestamp of the last change of the file description */
+       private $descriptionTouched;
+
        /** @var bool Whether the row was upgraded on load */
        private $upgraded;
 
@@ -278,7 +281,6 @@ class LocalFile extends File {
                        wfIncrStats( 'image_cache_miss' );
                }
 
-
                return $this->dataLoaded;
        }
 
@@ -1124,7 +1126,6 @@ class LocalFile extends File {
                }
 
                if ( !$props ) {
-                       wfProfileIn( __METHOD__ . '-getProps' );
                        if ( $this->repo->isVirtualUrl( $srcPath )
                                || FileBackend::isStoragePath( $srcPath )
                        ) {
@@ -1132,7 +1133,6 @@ class LocalFile extends File {
                        } else {
                                $props = FSFile::getPropsFromPath( $srcPath );
                        }
-                       wfProfileOut( __METHOD__ . '-getProps' );
                }
 
                $options = array();
@@ -1224,9 +1224,7 @@ class LocalFile extends File {
                $dbw->begin( __METHOD__ );
 
                if ( !$props ) {
-                       wfProfileIn( __METHOD__ . '-getProps' );
                        $props = $this->repo->getFileProps( $this->getVirtualUrl() );
-                       wfProfileOut( __METHOD__ . '-getProps' );
                }
 
                # Imports or such might force a certain timestamp; otherwise we generate
@@ -1382,7 +1380,6 @@ class LocalFile extends File {
                        // Page exists, do RC entry now (otherwise we wait for later).
                        $logEntry->publish( $logId );
                }
-               wfProfileIn( __METHOD__ . '-edit' );
 
                if ( $exists ) {
                        # Create a null revision
@@ -1449,22 +1446,16 @@ class LocalFile extends File {
                        $dbw->commit( __METHOD__ ); // commit before anything bad can happen
                }
 
-               wfProfileOut( __METHOD__ . '-edit' );
-
                if ( $reupload ) {
                        # Delete old thumbnails
-                       wfProfileIn( __METHOD__ . '-purge' );
                        $this->purgeThumbnails();
-                       wfProfileOut( __METHOD__ . '-purge' );
 
                        # Remove the old file from the squid cache
                        SquidUpdate::purge( array( $this->getURL() ) );
                }
 
                # Hooks, hooks, the magic of hooks...
-               wfProfileIn( __METHOD__ . '-hooks' );
                Hooks::run( 'FileUpload', array( $this, $reupload, $descTitle->exists() ) );
-               wfProfileOut( __METHOD__ . '-hooks' );
 
                # Invalidate cache for all pages using this file
                $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
@@ -1473,7 +1464,6 @@ class LocalFile extends File {
                        LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
                }
 
-
                return true;
        }
 
@@ -1790,6 +1780,22 @@ class LocalFile extends File {
                return $this->timestamp;
        }
 
+       /**
+        * @return bool|string
+        */
+       public function getDescriptionTouched() {
+               // The DB lookup might return false, e.g. if the file was just deleted, or the shared DB repo
+               // itself gets it from elsewhere. To avoid repeating the DB lookups in such a case, we
+               // need to differentiate between null (uninitialized) and false (failed to load).
+               if ( $this->descriptionTouched === null ) {
+                       $cond = array( 'page_namespace' => $this->title->getNamespace(), 'page_title' => $this->title->getDBkey() );
+                       $touched = $this->repo->getSlaveDB()->selectField( 'page', 'page_touched', $cond, __METHOD__ );
+                       $this->descriptionTouched = $touched ? wfTimestamp( TS_MW, $touched ) : false;
+               }
+
+               return $this->descriptionTouched;
+       }
+
        /**
         * @return string
         */