Conversation ID now gets set from initial notice.

This will work without much extra effort because there will always be
more notices (higher value) than conversations (so no collisions).

But please run upgrade.php to avoid having an autoincrement id on
conversation table.

Installations using code after 2014-03-01 will have identical
conversation IDs to the initial (conversation root) notice IDs. This
will not affect older installations, which will have very different
values.
This commit is contained in:
Mikael Nordfeldth
2014-03-01 17:06:29 +01:00
parent 9291225a69
commit 5c505d8539
3 changed files with 27 additions and 33 deletions

View File

@@ -165,12 +165,6 @@ class TwitterImport
}
}
if (empty($notice->conversation)) {
$conv = Conversation::create();
$notice->conversation = $conv->id;
common_log(LOG_INFO, "No known conversation for status {$statusId} so making a new one {$conv->id}.");
}
$notice->is_local = Notice::GATEWAY;
$notice->content = html_entity_decode($this->linkify($status, FALSE), ENT_QUOTES, 'UTF-8');
@@ -180,11 +174,19 @@ class TwitterImport
$id = $notice->insert();
if (!$id) {
if ($id === false) {
common_log_db_error($notice, 'INSERT', __FILE__);
common_log(LOG_ERR, __METHOD__ . ' - Problem saving notice.');
}
if (empty($notice->conversation)) {
$orig = clone($notice);
$conv = Conversation::create($notice);
common_log(LOG_INFO, "No known conversation for status {$statusId} so a new one ({$conv->id}) was created.");
$notice->conversation = $conv->id;
$notice->update($orig);
}
Event::handle('EndNoticeSave', array($notice));
}