The method was deprecated and made unnecessary in Ib308190c.
Change-Id: I1729ac0b3a88270a4c2f064187a2472112aaeb1e
}
$row = $this->getDatabaseArray( $dbw );
- $row['ipb_id'] = $dbw->nextSequenceValue( "ipblocks_ipb_id_seq" );
$dbw->insert( 'ipblocks', $row, __METHOD__, [ 'IGNORE' ] );
$affected = $dbw->affectedRows();
__METHOD__
);
if ( !$comment->id ) {
- $comment->id = $dbw->nextSequenceValue( 'comment_comment_id_seq' );
$dbw->insert(
'comment',
[
- 'comment_id' => $comment->id,
'comment_hash' => $hash,
'comment_text' => $comment->text,
'comment_data' => $dbData,
# 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_minor_edit' => $this->mMinorEdit ? 1 : 0,
? 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 );
$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 );
# Fixup database timestamps
$this->mAttribs['rc_timestamp'] = $dbw->timestamp( $this->mAttribs['rc_timestamp'] );
- $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' );
# # If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
if ( $this->mAttribs['rc_cur_id'] == 0 ) {
unset( $row['rc_comment'], $row['rc_comment_text'], $row['rc_comment_data'] );
$row += CommentStore::newKey( 'rc_comment' )->insert( $dbw, $comment );
+ # Don't reuse an existing rc_id for the new row, if one happens to be
+ # set for some reason.
+ unset( $row['rc_id'] );
+
# Insert new row
$dbw->insert( 'recentchanges', $row, __METHOD__ );
foreach ( $diffs as $url => $dummy ) {
foreach ( wfMakeUrlIndexes( $url ) as $index ) {
$arr[] = [
- 'el_id' => $this->getDB()->nextSequenceValue( 'externallinks_el_id_seq' ),
'el_from' => $this->mId,
'el_to' => $url,
'el_index' => $index,
public function store( $location, $data ) {
$dbw = $this->getMaster( $location );
- $id = $dbw->nextSequenceValue( 'blob_blob_id_seq' );
$dbw->insert( $this->getTable( $dbw ),
- [ 'blob_id' => $id, 'blob_text' => $data ],
+ [ 'blob_text' => $data ],
__METHOD__ );
$id = $dbw->insertId();
if ( !$id ) {
. $this->timestamp . "\n" );
return false;
}
- $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
$data = [
- 'log_id' => $log_id,
'log_type' => $this->type,
'log_action' => $this->action,
'log_timestamp' => $dbw->timestamp( $this->timestamp ),
'job_title' => $job->getTitle()->getDBkey(),
'job_params' => self::makeBlob( $job->getParams() ),
// Additional job metadata
- 'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
'job_timestamp' => $dbw->timestamp(),
'job_sha1' => Wikimedia\base_convert(
sha1( serialize( $job->getDeduplicationInfo() ) ),
/**
* Get the inserted value of an auto-increment row
*
- * The value inserted should be fetched from nextSequenceValue()
- *
- * Example:
- * $id = $dbw->nextSequenceValue( 'page_page_id_seq' );
- * $dbw->insert( 'page', [ 'page_id' => $id ] );
- * $id = $dbw->insertId();
+ * This should only be called after an insert that used an auto-incremented
+ * value. If no such insert was previously done in the current database
+ * session, the return value is undefined.
*
* @return int
*/
global $wgContLang;
$dbw = $dbw ?: wfGetDB( DB_MASTER );
- $id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
if ( $this->timestamp === null ) {
$this->timestamp = wfTimestampNow();
}
$data = [
- 'log_id' => $id,
'log_type' => $this->getType(),
'log_action' => $this->getSubtype(),
'log_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
global $wgLogRestrictions;
$dbw = wfGetDB( DB_MASTER );
- $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
// @todo FIXME private/protected/public property?
$this->timestamp = $now = wfTimestampNow();
$data = [
- 'log_id' => $log_id,
'log_type' => $this->type,
'log_action' => $this->action,
'log_timestamp' => $dbw->timestamp( $now ),
* page ID is already in use.
*/
public function insertOn( $dbw, $pageId = null ) {
- $pageIdForInsert = $pageId ?: $dbw->nextSequenceValue( 'page_page_id_seq' );
+ $pageIdForInsert = $pageId ? [ 'page_id' => $pageId ] : [];
$dbw->insert(
'page',
[
- 'page_id' => $pageIdForInsert,
'page_namespace' => $this->mTitle->getNamespace(),
'page_title' => $this->mTitle->getDBkey(),
'page_restrictions' => '',
'page_touched' => $dbw->timestamp(),
'page_latest' => 0, // Fill this in shortly...
'page_len' => 0, // Fill this in shortly...
- ],
+ ] + $pageIdForInsert,
__METHOD__,
'IGNORE'
);
$dbw->insert(
'page_restrictions',
[
- 'pr_id' => $dbw->nextSequenceValue( 'page_restrictions_pr_id_seq' ),
'pr_page' => $id,
'pr_type' => $action,
'pr_level' => $restrictions,
'sites', $fields, [ 'site_id' => $rowId ], __METHOD__
) && $success;
} else {
- $rowId = $dbw->nextSequenceValue( 'sites_site_id_seq' );
- $fields['site_id'] = $rowId;
$success = $dbw->insert( 'sites', $fields, __METHOD__ ) && $success;
$rowId = $dbw->insertId();
}
}
$this->fileMetadata[$key] = [
- 'us_id' => $dbw->nextSequenceValue( 'uploadstash_us_id_seq' ),
'us_user' => $this->userId,
'us_key' => $key,
'us_orig_path' => $path,
unset( $params['options'] );
}
$dbw = wfGetDB( DB_MASTER );
- $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
$noPass = PasswordFactory::newInvalidPassword()->toString();
$fields = [
- 'user_id' => $seqVal,
'user_name' => $name,
'user_password' => $noPass,
'user_newpassword' => $noPass,
$noPass = PasswordFactory::newInvalidPassword()->toString();
$dbw = wfGetDB( DB_MASTER );
- $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
$dbw->insert( 'user',
[
- 'user_id' => $seqVal,
'user_name' => $this->mName,
'user_password' => $noPass,
'user_newpassword' => $noPass,
$db->insert( 'externallinks',
[
[
- 'el_id' => $db->nextSequenceValue( 'externallinks_el_id_seq' ),
'el_from' => $row->el_from,
'el_to' => $row->el_to,
'el_index' => "http:{$row->el_index}",
],
[
- 'el_id' => $db->nextSequenceValue( 'externallinks_el_id_seq' ),
'el_from' => $row->el_from,
'el_to' => $row->el_to,
'el_index' => "https:{$row->el_index}",
$this->assertArrayNotHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
}
- $extraFields[$pk] = $this->db->nextSequenceValue( "{$table}_{$pk}_seq" );
$this->db->insert( $table, $extraFields + $fields, __METHOD__ );
$id = $this->db->insertId();
if ( $usesTemp ) {