X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FLocalFile.php;h=4c0dea246e9a9352bad1d8d63a258ed0f7a973f4;hp=904c932d58b28821eb4127ba367d60593a004d65;hb=ab4e6fdd516ee51ee20235cdedd67a777cc5d018;hpb=802c199d0bd80ff0f4d730c61fd58cbf08a52d8d diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 904c932d58..4c0dea246e 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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' ] @@ -1195,8 +1199,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 +1232,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 +1555,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 +1563,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(); }