Merge pull request #5261 from annando/and-again-abstraction

And again the item abstraction - and a fix for issue 5252
This commit is contained in:
Hypolite Petovan 2018-06-21 11:50:31 -04:00 committed by GitHub
commit 8a3cae686b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 129 additions and 127 deletions

View file

@ -64,7 +64,7 @@ class Delivery extends BaseObject
$itemdata = Item::select([], $condition, $params);
$items = [];
while ($item = dba::fetch($itemdata)) {
while ($item = Item::fetch($itemdata)) {
if ($item['id'] == $parent_id) {
$parent = $item;
}

View file

@ -124,7 +124,7 @@ class Notifier {
return;
}
$items = dba::inArray($ret);
$items = Item::inArray($ret);
// avoid race condition with deleting entries
if ($items[0]['deleted']) {

View file

@ -438,12 +438,10 @@ class OnePoll
$refs_arr[$x] = "'" . Email::msgid2iri(str_replace(['<', '>', ' '],['', '', ''],dbesc($refs_arr[$x]))) . "'";
}
}
$qstr = implode(',', $refs_arr);
$r = q("SELECT `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1",
intval($importer_uid)
);
if (DBM::is_result($r)) {
$datarray['parent-uri'] = $r[0]['parent-uri']; // Set the parent as the top-level item
$condition = ['uri' => $refs_arr, 'uid' => $importer_uid];
$parent = Item::selectFirst(['parent-uri'], $condition);
if (DBM::is_result($parent)) {
$datarray['parent-uri'] = $parent['parent-uri']; // Set the parent as the top-level item
}
}
@ -472,12 +470,11 @@ class OnePoll
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
if (empty($datarray['parent-uri']) && $reply) {
$r = q("SELECT `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d AND `network` = '%s' ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid),
dbesc(NETWORK_MAIL));
if (DBM::is_result($r)) {
$datarray['parent-uri'] = $r[0]['parent-uri'];
$condition = ['title' => $datarray['title'], 'uid' => importer_uid, 'network' => NETWORK_MAIL];
$params = ['order' => ['created' => true]];
$parent = Item::selectFirst(['parent-uri'], $condition, $params);
if (DBM::is_result($parent)) {
$datarray['parent-uri'] = $parent['parent-uri'];
}
}

View file

@ -27,7 +27,7 @@ class TagUpdate
dba::close($messages);
$messages = dba::p("SELECT `guid` FROM `item` WHERE `uid` = 0");
$messages = dba::select('item', ['guid'], ['uid' => 0]);
logger('fetched messages: ' . dba::num_rows($messages));
while ($message = dba::fetch(messages)) {