$page = WikiPage::factory( $this->title );
$page->loadPageData( 'fromdbmaster' );
if ( !$page->exists() ) {
- # must create the page...
+ // must create the page...
$pageId = $page->insertOn( $dbw );
$created = true;
$oldcountable = null;
}
}
+ if ( !$pageId ) {
+ // This seems to happen if two clients simultaneously try to import the
+ // same page
+ wfDebug( __METHOD__ . ': got invalid $pageId when importing revision of [[' .
+ $this->title->getPrefixedText() . ']], timestamp ' . $this->timestamp . "\n" );
+ return false;
+ }
+
// Select previous version to make size diffs correct
+ // @todo This assumes that multiple revisions of the same page are imported
+ // in order from oldest to newest.
$prevId = $dbw->selectField( 'revision', 'rev_id',
array(
'rev_page' => $pageId,
- 'rev_timestamp <= ' . $dbw->timestamp( $this->timestamp ),
+ 'rev_timestamp <= ' . $dbw->addQuotes( $dbw->timestamp( $this->timestamp ) ),
),
__METHOD__,
array( 'ORDER BY' => array(
function importLogItem() {
$dbw = wfGetDB( DB_MASTER );
+
+ $user = User::newFromName( $this->getUser() );
+ if ( $user ) {
+ $userId = intval( $user->getId() );
+ $userText = $user->getName();
+ } else {
+ $userId = 0;
+ $userText = $this->getUser();
+ }
+
# @todo FIXME: This will not record autoblocks
if ( !$this->getTitle() ) {
wfDebug( __METHOD__ . ": skipping invalid {$this->type}/{$this->action} log time, timestamp " .
'log_type' => $this->type,
'log_action' => $this->action,
'log_timestamp' => $dbw->timestamp( $this->timestamp ),
- 'log_user' => User::idFromName( $this->user_text ),
- # 'log_user_text' => $this->user_text,
+ 'log_user' => $userId,
+ 'log_user_text' => $userText,
'log_namespace' => $this->getTitle()->getNamespace(),
'log_title' => $this->getTitle()->getDBkey(),
'log_comment' => $this->getComment(),