}
}
+ // Select previous version to make size diffs correct
+ $prevId = $dbw->selectField( 'revision', 'rev_id',
+ array(
+ 'rev_page' => $pageId,
+ 'rev_timestamp <= ' . $dbw->timestamp( $this->timestamp ),
+ ),
+ __METHOD__,
+ array( 'ORDER BY' => array(
+ 'rev_timestamp DESC',
+ 'rev_id DESC', // timestamp is not unique per page
+ )
+ )
+ );
+
# @todo FIXME: Use original rev_id optionally (better for backups)
# Insert the row
$revision = new Revision( array(
'user_text' => $userText,
'timestamp' => $this->timestamp,
'minor_edit' => $this->minor,
+ 'parent_id' => $prevId,
) );
$revision->insertOn( $dbw );
$changed = $page->updateIfNewerOn( $dbw, $revision );