$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,
/**
* 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() {
'rev_page',
'rev_text_id',
'rev_timestamp',
- 'rev_comment',
'rev_user_text',
'rev_user',
'rev_minor_edit',
'rev_sha1',
];
+ $fields += CommentStore::newKey( 'rev_comment' )->getFields();
+
if ( $wgContentHandlerUseDB ) {
$fields[] = 'rev_content_format';
$fields[] = 'rev_content_model';
/**
* 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() {
'ar_text',
'ar_text_id',
'ar_timestamp',
- 'ar_comment',
'ar_user_text',
'ar_user',
'ar_minor_edit',
'ar_sha1',
];
+ $fields += CommentStore::newKey( 'ar_comment' )->getFields();
+
if ( $wgContentHandlerUseDB ) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
$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;
* 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 ) {
*
* @param IDatabase $dbw (master connection)
* @throws MWException
- * @return int
+ * @return int The revision ID
*/
public function insertOn( $dbw ) {
global $wgDefaultExternalStore, $wgContentHandlerUseDB;
# Record the text (or external storage URL) to the text table
if ( $this->mTextId === null ) {
- $old_id = $dbw->nextSequenceValue( 'text_old_id_seq' );
$dbw->insert( 'text',
[
- 'old_id' => $old_id,
'old_text' => $data,
'old_flags' => $flags,
], __METHOD__
}
# Record the edit in revisions
- $rev_id = $this->mId !== null
- ? $this->mId
- : $dbw->nextSequenceValue( 'revision_rev_id_seq' );
$row = [
- '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,
? self::base36Sha1( $this->mText )
: $this->mSha1,
];
+ if ( $this->mId !== null ) {
+ $row['rev_id'] = $this->mId;
+ }
+
+ 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.
$dbw->insert( 'revision', $row, __METHOD__ );
if ( $this->mId === null ) {
- // Only if nextSequenceValue() was called
+ // Only if auto-increment was used
$this->mId = $dbw->insertId();
}
+ $commentCallback( $this->mId );
// Assertion to try to catch T92046
if ( (int)$this->mId === 0 ) {
);
}
+ // Insert IP revision into ip_changes for use when querying for a range.
+ if ( $this->mUser === 0 && IP::isValid( $this->mUserText ) ) {
+ $ipcRow = [
+ 'ipc_rev_id' => $this->mId,
+ 'ipc_rev_timestamp' => $row['rev_timestamp'],
+ 'ipc_hex' => IP::toHex( $row['rev_user_text'] ),
+ ];
+ $dbw->insert( 'ip_changes', $ipcRow, __METHOD__ );
+ }
+
// Avoid PHP 7.1 warning of passing $this by reference
$revision = $this;
Hooks::run( 'RevisionInsertComplete', [ &$revision, $data, $flags ] );
* Get the text cache TTL
*
* @param WANObjectCache $cache
- * @return integer
+ * @return int
*/
private static function getCacheTTL( WANObjectCache $cache ) {
global $wgRevisionCacheExpiry;
* @return Revision|null Revision or null on error
*/
public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
- global $wgContentHandlerUseDB, $wgContLang;
+ global $wgContentHandlerUseDB;
$fields = [ 'page_latest', 'page_namespace', 'page_title',
'rev_text_id', 'rev_len', 'rev_sha1' ];
$user = $wgUser;
}
- // Truncate for whole multibyte characters
- $summary = $wgContLang->truncate( $summary, 255 );
-
$row = [
'page' => $pageId,
'user_text' => $user->getName(),