Merge "FeedbackDialog: Improve alignment"
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 904c932..8aea7ab 100644 (file)
@@ -347,7 +347,7 @@ 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 == '' ) {
@@ -359,6 +359,7 @@ class LocalFile extends File {
                        foreach ( $fields as $field ) {
                                $prefixedFields[] = $prefix . $field;
                        }
+                       $prefixedFields += CommentStore::newKey( "{$prefix}description" )->getFields();
                        $results[$prefix] = $prefixedFields;
                }
 
@@ -536,6 +537,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 ) {
@@ -1195,8 +1200,6 @@ class LocalFile extends File {
        function upload( $src, $comment, $pageText, $flags = 0, $props = false,
                $timestamp = false, $user = null, $tags = []
        ) {
-               global $wgContLang;
-
                if ( $this->getRepo()->getReadOnlyReason() !== false ) {
                        return $this->readOnlyFatalStatus();
                }
@@ -1230,9 +1233,6 @@ class LocalFile extends File {
                // Trim spaces on user supplied text
                $comment = trim( $comment );
 
-               // Truncate nicely or the DB will do it for us
-               // non-nicely (dangling multi-byte chars, non-truncated version in cache).
-               $comment = $wgContLang->truncate( $comment, 255 );
                $this->lock(); // begin
                $status = $this->publish( $src, $flags, $options );
 
@@ -1556,7 +1556,7 @@ class LocalFile extends File {
                                                );
 
                                                if ( isset( $status->value['revision'] ) ) {
-                                                       /** @var $rev Revision */
+                                                       /** @var Revision $rev */
                                                        $rev = $status->value['revision'];
                                                        // Associate new page revision id
                                                        $logEntry->setAssociatedRevId( $rev->getId() );
@@ -1564,7 +1564,7 @@ class LocalFile extends File {
                                                // This relies on the resetArticleID() call in WikiPage::insertOn(),
                                                // which is triggered on $descTitle by doEditContent() above.
                                                if ( isset( $status->value['revision'] ) ) {
-                                                       /** @var $rev Revision */
+                                                       /** @var Revision $rev */
                                                        $rev = $status->value['revision'];
                                                        $updateLogPage = $rev->getPage();
                                                }