X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Ffilerepo%2Ffile%2FOldLocalFile.php;h=ee172e114379f998fb1b8f9e97ac2968dfcc615f;hb=2480aae0c97d822e10b50619e7b48b25c45af073;hp=06fef4f6f08dcb7cf685900c86fbddd4c8e1f8c5;hpb=05c72943a7bb06f618c7bd6f01cbbc2ce0665178;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/file/OldLocalFile.php b/includes/filerepo/file/OldLocalFile.php index 06fef4f6f0..ee172e1143 100644 --- a/includes/filerepo/file/OldLocalFile.php +++ b/includes/filerepo/file/OldLocalFile.php @@ -86,7 +86,7 @@ class OldLocalFile extends LocalFile { * @return bool|OldLocalFile */ static function newFromKey( $sha1, $repo, $timestamp = false ) { - $dbr = $repo->getSlaveDB(); + $dbr = $repo->getReplicaDB(); $conds = [ 'oi_sha1' => $sha1 ]; if ( $timestamp ) { @@ -103,6 +103,8 @@ class OldLocalFile extends LocalFile { /** * Fields in the oldimage table + * @todo Deprecate this in favor of a method that returns tables and joins + * as well, and use CommentStore::getJoin(). * @return array */ static function selectFields() { @@ -117,13 +119,12 @@ class OldLocalFile extends LocalFile { 'oi_media_type', 'oi_major_mime', 'oi_minor_mime', - 'oi_description', 'oi_user', 'oi_user_text', 'oi_timestamp', 'oi_deleted', 'oi_sha1', - ]; + ] + CommentStore::newKey( 'oi_description' )->getFields(); } /** @@ -179,7 +180,7 @@ class OldLocalFile extends LocalFile { $dbr = ( $flags & self::READ_LATEST ) ? $this->repo->getMasterDB() - : $this->repo->getSlaveDB(); + : $this->repo->getReplicaDB(); $conds = [ 'oi_name' => $this->getName() ]; if ( is_null( $this->requestedTime ) ) { @@ -201,7 +202,7 @@ class OldLocalFile extends LocalFile { */ protected function loadExtraFromDB() { $this->extraDataLoaded = true; - $dbr = $this->repo->getSlaveDB(); + $dbr = $this->repo->getReplicaDB(); $conds = [ 'oi_name' => $this->getName() ]; if ( is_null( $this->requestedTime ) ) { $conds['oi_archive_name'] = $this->archive_name; @@ -367,6 +368,7 @@ class OldLocalFile extends LocalFile { return false; } + $commentFields = CommentStore::newKey( 'oi_description' )->insert( $dbw, $comment ); $dbw->insert( 'oldimage', [ 'oi_name' => $this->getName(), @@ -376,7 +378,6 @@ class OldLocalFile extends LocalFile { 'oi_height' => intval( $props['height'] ), 'oi_bits' => $props['bits'], 'oi_timestamp' => $dbw->timestamp( $timestamp ), - 'oi_description' => $comment, 'oi_user' => $user->getId(), 'oi_user_text' => $user->getName(), 'oi_metadata' => $props['metadata'], @@ -384,7 +385,7 @@ class OldLocalFile extends LocalFile { 'oi_major_mime' => $props['major_mime'], 'oi_minor_mime' => $props['minor_mime'], 'oi_sha1' => $props['sha1'], - ], __METHOD__ + ] + $commentFields, __METHOD__ ); return true; @@ -395,6 +396,7 @@ class OldLocalFile extends LocalFile { * * This is the case for a couple files on Wikimedia servers where * the old version is "lost". + * @return bool */ public function exists() { $archiveName = $this->getArchiveName();