X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FRevision.php;h=ff4a28438608bb21f5723aba2f55db1bd1ef27d8;hp=c3782ba18a9af2f3a5de40e83b387938d0beec38;hb=802c199d0bd80ff0f4d730c61fd58cbf08a52d8d;hpb=12601ff7d2796752404bfb331fccc41083d31f9f diff --git a/includes/Revision.php b/includes/Revision.php index c3782ba18a..ff4a284386 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -192,7 +192,9 @@ class Revision implements IDBAccessObject { $attribs = $overrides + [ 'page' => isset( $row->ar_page_id ) ? $row->ar_page_id : null, 'id' => isset( $row->ar_rev_id ) ? $row->ar_rev_id : null, - 'comment' => $row->ar_comment, + 'comment' => CommentStore::newKey( 'ar_comment' ) + // Legacy because $row probably came from self::selectArchiveFields() + ->getCommentLegacy( wfGetDB( DB_REPLICA ), $row, true )->text, 'user' => $row->ar_user, 'user_text' => $row->ar_user_text, 'timestamp' => $row->ar_timestamp, @@ -443,6 +445,8 @@ class Revision implements IDBAccessObject { /** * Return the list of revision fields that should be selected to create * a new revision. + * @todo Deprecate this in favor of a method that returns tables and joins + * as well, and use CommentStore::getJoin(). * @return array */ public static function selectFields() { @@ -453,7 +457,6 @@ class Revision implements IDBAccessObject { 'rev_page', 'rev_text_id', 'rev_timestamp', - 'rev_comment', 'rev_user_text', 'rev_user', 'rev_minor_edit', @@ -463,6 +466,8 @@ class Revision implements IDBAccessObject { 'rev_sha1', ]; + $fields += CommentStore::newKey( 'rev_comment' )->getFields(); + if ( $wgContentHandlerUseDB ) { $fields[] = 'rev_content_format'; $fields[] = 'rev_content_model'; @@ -474,6 +479,8 @@ class Revision implements IDBAccessObject { /** * Return the list of revision fields that should be selected to create * a new revision from an archive row. + * @todo Deprecate this in favor of a method that returns tables and joins + * as well, and use CommentStore::getJoin(). * @return array */ public static function selectArchiveFields() { @@ -485,7 +492,6 @@ class Revision implements IDBAccessObject { 'ar_text', 'ar_text_id', 'ar_timestamp', - 'ar_comment', 'ar_user_text', 'ar_user', 'ar_minor_edit', @@ -495,6 +501,8 @@ class Revision implements IDBAccessObject { 'ar_sha1', ]; + $fields += CommentStore::newKey( 'ar_comment' )->getFields(); + if ( $wgContentHandlerUseDB ) { $fields[] = 'ar_content_format'; $fields[] = 'ar_content_model'; @@ -559,8 +567,6 @@ class Revision implements IDBAccessObject { } /** - * Constructor - * * @param object|array $row Either a database row or an array * @throws MWException * @access private @@ -570,7 +576,9 @@ class Revision implements IDBAccessObject { $this->mId = intval( $row->rev_id ); $this->mPage = intval( $row->rev_page ); $this->mTextId = intval( $row->rev_text_id ); - $this->mComment = $row->rev_comment; + $this->mComment = CommentStore::newKey( 'rev_comment' ) + // Legacy because $row probably came from self::selectFields() + ->getCommentLegacy( wfGetDB( DB_REPLICA ), $row, true )->text; $this->mUser = intval( $row->rev_user ); $this->mMinorEdit = intval( $row->rev_minor_edit ); $this->mTimestamp = $row->rev_timestamp; @@ -754,7 +762,7 @@ class Revision implements IDBAccessObject { * This should only be used for proposed revisions that turn out to be null edits * * @since 1.28 - * @param integer $id User ID + * @param int $id User ID * @param string $name User name */ public function setUserIdAndName( $id, $name ) { @@ -862,7 +870,7 @@ class Revision implements IDBAccessObject { * Revision::FOR_PUBLIC to be displayed to all users * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the ID regardless of permissions - * @param User $user User object to check for, only if FOR_THIS_USER is passed + * @param User|null $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter * @return int */ @@ -896,7 +904,7 @@ class Revision implements IDBAccessObject { * Revision::FOR_PUBLIC to be displayed to all users * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the text regardless of permissions - * @param User $user User object to check for, only if FOR_THIS_USER is passed + * @param User|null $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter * @return string */ @@ -940,7 +948,7 @@ class Revision implements IDBAccessObject { * Revision::FOR_PUBLIC to be displayed to all users * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the text regardless of permissions - * @param User $user User object to check for, only if FOR_THIS_USER is passed + * @param User|null $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter * @return string */ @@ -1004,7 +1012,7 @@ class Revision implements IDBAccessObject { return RecentChange::newFromConds( [ - 'rc_user_text' => $this->getUserText( Revision::RAW ), + 'rc_user_text' => $this->getUserText( self::RAW ), 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ), 'rc_this_oldid' => $this->getId() ], @@ -1309,7 +1317,7 @@ class Revision implements IDBAccessObject { * data is compressed, and 'utf-8' if we're saving in UTF-8 * mode. * - * @param mixed $text Reference to a text + * @param mixed &$text Reference to a text * @return string */ public static function compressRevisionText( &$text ) { @@ -1457,7 +1465,6 @@ class Revision implements IDBAccessObject { 'rev_id' => $rev_id, 'rev_page' => $this->mPage, 'rev_text_id' => $this->mTextId, - 'rev_comment' => $this->mComment, 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0, 'rev_user' => $this->mUser, 'rev_user_text' => $this->mUserText, @@ -1468,10 +1475,14 @@ class Revision implements IDBAccessObject { ? $this->getPreviousRevisionId( $dbw ) : $this->mParentId, 'rev_sha1' => $this->mSha1 === null - ? Revision::base36Sha1( $this->mText ) + ? self::base36Sha1( $this->mText ) : $this->mSha1, ]; + list( $commentFields, $commentCallback ) = + CommentStore::newKey( 'rev_comment' )->insertWithTempTable( $dbw, $this->mComment ); + $row += $commentFields; + if ( $wgContentHandlerUseDB ) { // NOTE: Store null for the default model and format, to save space. // XXX: Makes the DB sensitive to changed defaults. @@ -1500,6 +1511,7 @@ class Revision implements IDBAccessObject { // Only if nextSequenceValue() was called $this->mId = $dbw->insertId(); } + $commentCallback( $this->mId ); // Assertion to try to catch T92046 if ( (int)$this->mId === 0 ) { @@ -1557,7 +1569,7 @@ class Revision implements IDBAccessObject { } } - $content = $this->getContent( Revision::RAW ); + $content = $this->getContent( self::RAW ); $prefixedDBkey = $title->getPrefixedDBkey(); $revId = $this->mId; @@ -1586,7 +1598,7 @@ class Revision implements IDBAccessObject { * Get the text cache TTL * * @param WANObjectCache $cache - * @return integer + * @return int */ private static function getCacheTTL( WANObjectCache $cache ) { global $wgRevisionCacheExpiry;