Bump LocalFile::VERSION to invalidate file page cache
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 810f788..a623c54 100644 (file)
@@ -43,7 +43,7 @@ use Wikimedia\Rdbms\IDatabase;
  * @ingroup FileAbstraction
  */
 class LocalFile extends File {
-       const VERSION = 10; // cache version
+       const VERSION = 11; // cache version
 
        const CACHE_FIELD_MAX_LEN = 1000;
 
@@ -347,18 +347,18 @@ class LocalFile extends File {
        function getCacheFields( $prefix = 'img_' ) {
                static $fields = [ 'size', 'width', 'height', 'bits', 'media_type',
                        'major_mime', 'minor_mime', 'metadata', 'timestamp', 'sha1', 'user',
-                       'user_text', 'description' ];
+                       'user_text' ];
                static $results = [];
 
                if ( $prefix == '' ) {
-                       return $fields;
+                       return array_merge( $fields, [ 'description' ] );
                }
-
                if ( !isset( $results[$prefix] ) ) {
                        $prefixedFields = [];
                        foreach ( $fields as $field ) {
                                $prefixedFields[] = $prefix . $field;
                        }
+                       $prefixedFields += CommentStore::newKey( "{$prefix}description" )->getFields();
                        $results[$prefix] = $prefixedFields;
                }
 
@@ -536,6 +536,10 @@ class LocalFile extends File {
                $this->dataLoaded = true;
                $this->extraDataLoaded = true;
 
+               $this->description = CommentStore::newKey( "{$prefix}description" )
+                       // $row is probably using getFields() from self::getCacheFields()
+                       ->getCommentLegacy( wfGetDB( DB_REPLICA ), $row )->text;
+
                $array = $this->decodeRow( $row, $prefix );
 
                foreach ( $array as $name => $value ) {
@@ -1124,11 +1128,9 @@ class LocalFile extends File {
 
                if ( $this->historyLine == 0 ) { // called for the first time, return line from cur
                        $this->historyRes = $dbr->select( 'image',
-                               [
-                                       '*',
-                                       "'' AS oi_archive_name",
-                                       '0 as oi_deleted',
-                                       'img_sha1'
+                               self::selectFields() + [
+                                       'oi_archive_name' => $dbr->addQuotes( '' ),
+                                       'oi_deleted' => 0,
                                ],
                                [ 'img_name' => $this->title->getDBkey() ],
                                $fname
@@ -1140,7 +1142,9 @@ class LocalFile extends File {
                                return false;
                        }
                } elseif ( $this->historyLine == 1 ) {
-                       $this->historyRes = $dbr->select( 'oldimage', '*',
+                       $this->historyRes = $dbr->select(
+                               'oldimage',
+                               OldLocalFile::selectFields(),
                                [ 'oi_name' => $this->title->getDBkey() ],
                                $fname,
                                [ 'ORDER BY' => 'oi_timestamp DESC' ]