Merge pull request #518 from annando/item-isolation
Direct calls to the database are replaced by calls to the item class
This commit is contained in:
commit
d38987896c
|
@ -543,10 +543,7 @@ function pumpio_send(&$a,&$b) {
|
||||||
logger('pumpio_send '.$username.': success '.$post_id);
|
logger('pumpio_send '.$username.': success '.$post_id);
|
||||||
if($post_id && $iscomment) {
|
if($post_id && $iscomment) {
|
||||||
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
|
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
|
||||||
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
|
Item::update(['extid' => $post_id], ['id' => $b['id']]);
|
||||||
dbesc($post_id),
|
|
||||||
intval($b['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user,true));
|
logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user,true));
|
||||||
|
@ -870,13 +867,7 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) {
|
||||||
$contactid = $orig_post['contact-id'];
|
$contactid = $orig_post['contact-id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `verb` = '%s' AND `uid` = %d AND `contact-id` = %d AND `thr-parent` = '%s'",
|
Item::delete(['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
|
||||||
dbesc(DateTimeFormat::utcNow()),
|
|
||||||
dbesc(ACTIVITY_LIKE),
|
|
||||||
intval($uid),
|
|
||||||
intval($contactid),
|
|
||||||
dbesc($orig_post['uri'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if(count($r))
|
if(count($r))
|
||||||
logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
|
||||||
|
@ -1060,7 +1051,7 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($r))
|
if (count($r))
|
||||||
return Item::delete($r[0]["id"]);
|
return Item::deleteById($r[0]["id"]);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
dbesc($post->object->id),
|
dbesc($post->object->id),
|
||||||
|
@ -1068,7 +1059,7 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($r))
|
if (count($r))
|
||||||
return Item::delete($r[0]["id"]);
|
return Item::deleteById($r[0]["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcompletion = true) {
|
function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcompletion = true) {
|
||||||
|
@ -1256,13 +1247,9 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
||||||
$postarray["id"] = $top_item;
|
$postarray["id"] = $top_item;
|
||||||
|
|
||||||
if (($top_item == 0) && ($post->verb == "update")) {
|
if (($top_item == 0) && ($post->verb == "update")) {
|
||||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s' , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
$fields = ['title' => $postarray["title"], 'body' => $postarray["body"], 'changed' => $postarray["edited"]];
|
||||||
dbesc($postarray["title"]),
|
$condition = ['uri' => $postarray["uri"], 'uid' => $uid];
|
||||||
dbesc($postarray["body"]),
|
Item::update($fields, $condition);
|
||||||
dbesc($postarray["edited"]),
|
|
||||||
dbesc($postarray["uri"]),
|
|
||||||
intval($uid)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($post->object->objectType == "comment") {
|
if ($post->object->objectType == "comment") {
|
||||||
|
@ -1491,10 +1478,7 @@ function pumpio_queue_hook(&$a,&$b) {
|
||||||
logger('pumpio_queue: send '.$username.': success '.$post_id);
|
logger('pumpio_queue: send '.$username.': success '.$post_id);
|
||||||
if($post_id && $iscomment) {
|
if($post_id && $iscomment) {
|
||||||
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
|
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
|
||||||
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
|
Item::update(['extid' => $post_id], ['id' => $z['item']]);
|
||||||
dbesc($post_id),
|
|
||||||
intval($z['item'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Queue::removeItem($x['id']);
|
Queue::removeItem($x['id']);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -600,11 +600,7 @@ function statusnet_post_hook(App $a, &$b)
|
||||||
logger('Send to GNU Social failed: "' . $result->error . '"');
|
logger('Send to GNU Social failed: "' . $result->error . '"');
|
||||||
} elseif ($iscomment) {
|
} elseif ($iscomment) {
|
||||||
logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']);
|
logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']);
|
||||||
q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
|
Item::update(['extid' => $hostname . "::" . $result->id, 'body' => $result->text], ['id' => $b['id']]);
|
||||||
dbesc($hostname . "::" . $result->id),
|
|
||||||
dbesc($result->text),
|
|
||||||
intval($b['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($tempfile != "") {
|
if ($tempfile != "") {
|
||||||
|
|
|
@ -571,11 +571,7 @@ function twitter_post_hook(App $a, &$b)
|
||||||
$image = "";
|
$image = "";
|
||||||
} elseif ($iscomment) {
|
} elseif ($iscomment) {
|
||||||
logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
||||||
q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
|
Item::update(['extid' => "twitter::" . $result->id_str, 'body' => $result->text], ['id' => $b['id']]);
|
||||||
dbesc("twitter::" . $result->id_str),
|
|
||||||
dbesc($result->text),
|
|
||||||
intval($b['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,10 +617,7 @@ function twitter_post_hook(App $a, &$b)
|
||||||
notice(L10n::t('Twitter post failed. Queued for retry.') . EOL);
|
notice(L10n::t('Twitter post failed. Queued for retry.') . EOL);
|
||||||
} elseif ($iscomment) {
|
} elseif ($iscomment) {
|
||||||
logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
||||||
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
|
Item::update(['extid' => "twitter::" . $result->id_str], ['id' => $b['id']]);
|
||||||
dbesc("twitter::" . $result->id_str),
|
|
||||||
intval($b['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue