Merge pull request #5030 from annando/fix-sql
Fix SQL error during postupdate
This commit is contained in:
commit
d4e3f3f4bb
3 changed files with 16 additions and 5 deletions
|
@ -120,7 +120,8 @@ class PostUpdate
|
||||||
logger("Start", LOGGER_DEBUG);
|
logger("Start", LOGGER_DEBUG);
|
||||||
|
|
||||||
// Check if the first step is done (Setting "author-id" and "owner-id" in the item table)
|
// Check if the first step is done (Setting "author-id" and "owner-id" in the item table)
|
||||||
$r = dba::select('item', ['author-link', 'owner-link', 'uid'], ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]);
|
$fields = ['author-link', 'author-name', 'author-avatar', 'owner-link', 'owner-name', 'owner-avatar', 'network', 'uid'];
|
||||||
|
$r = dba::select('item', $fields, ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]);
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
// Are there unfinished entries in the thread table?
|
// Are there unfinished entries in the thread table?
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `thread`
|
$r = q("SELECT COUNT(*) AS `total` FROM `thread`
|
||||||
|
@ -162,8 +163,13 @@ class PostUpdate
|
||||||
|
|
||||||
// Set the "author-id" and "owner-id" in the item table and add a new public contact entry if needed
|
// Set the "author-id" and "owner-id" in the item table and add a new public contact entry if needed
|
||||||
foreach ($item_arr as $item) {
|
foreach ($item_arr as $item) {
|
||||||
$author_id = Contact::getIdForURL($item["author-link"]);
|
$default = ['url' => $item['author-link'], 'name' => $item['author-name'],
|
||||||
$owner_id = Contact::getIdForURL($item["owner-link"]);
|
'photo' => $item['author-avatar'], 'network' => $item['network']];
|
||||||
|
$author_id = Contact::getIdForURL($item["author-link"], 0, false, $default);
|
||||||
|
|
||||||
|
$default = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
|
||||||
|
'photo' => $item['owner-avatar'], 'network' => $item['network']];
|
||||||
|
$owner_id = Contact::getIdForURL($item["owner-link"], 0, false, $default);
|
||||||
|
|
||||||
if ($author_id == 0) {
|
if ($author_id == 0) {
|
||||||
$author_id = -1;
|
$author_id = -1;
|
||||||
|
|
|
@ -2047,7 +2047,7 @@ EOT;
|
||||||
|
|
||||||
$result = dba::update('thread', $fields, ['iid' => $itemid]);
|
$result = dba::update('thread', $fields, ['iid' => $itemid]);
|
||||||
|
|
||||||
logger("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result." ".print_r($item, true), LOGGER_DEBUG);
|
logger("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result, LOGGER_DEBUG);
|
||||||
|
|
||||||
// Updating a shadow item entry
|
// Updating a shadow item entry
|
||||||
$items = dba::selectFirst('item', ['id'], ['guid' => $item['guid'], 'uid' => 0]);
|
$items = dba::selectFirst('item', ['id'], ['guid' => $item['guid'], 'uid' => 0]);
|
||||||
|
|
|
@ -522,7 +522,12 @@ class PortableContact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['updated' => $last_updated, 'last_contact' => DateTimeFormat::utcNow()];
|
$fields = ['last_contact' => DateTimeFormat::utcNow()];
|
||||||
|
|
||||||
|
if (!empty($last_updated)) {
|
||||||
|
$fields['updated'] = $last_updated;
|
||||||
|
}
|
||||||
|
|
||||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||||
|
|
||||||
if (($gcontacts[0]["generation"] == 0)) {
|
if (($gcontacts[0]["generation"] == 0)) {
|
||||||
|
|
Loading…
Reference in a new issue