Old database functions had been replaced in the workers

This commit is contained in:
Michael 2018-04-09 21:34:23 +00:00
parent 66bcbe210a
commit 08abf65f7b
6 changed files with 24 additions and 29 deletions

View File

@ -208,7 +208,7 @@ class Delivery {
$atom = DFRN::mail($item, $owner);
} elseif ($fsuggest) {
$atom = DFRN::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
dba::delete('fsuggest', ['id' => $item['id']]);
} elseif ($relocate) {
$atom = DFRN::relocate($owner, $uid);
} elseif ($followup) {
@ -290,9 +290,7 @@ class Delivery {
if ($x && count($x)) {
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
if ((($owner['page-flags'] == PAGE_COMMUNITY) || $write_flag) && !$x[0]['writable']) {
q("UPDATE `contact` SET `writable` = 1 WHERE `id` = %d",
intval($x[0]['id'])
);
dba::update('contact', ['writable' => true], ['id' => $x[0]['id']]);
$x[0]['writable'] = 1;
}

View File

@ -13,6 +13,7 @@ use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use dba;
class DiscoverPoCo {
/// @todo Clean up this mess of a parameter hell and split it in several classes
@ -158,8 +159,8 @@ class DiscoverPoCo {
$urlparts = parse_url($user["url"]);
if (!isset($urlparts["scheme"])) {
q("UPDATE `gcontact` SET `network` = '%s' WHERE `nurl` = '%s'",
dbesc(NETWORK_PHANTOM), dbesc(normalise_link($user["url"])));
dba::update('gcontact', ['network' => NETWORK_PHANTOM],
['nurl' => normalise_link($user["url"])]);
continue;
}
@ -171,8 +172,8 @@ class DiscoverPoCo {
"identi.ca" => NETWORK_PUMPIO,
"alpha.app.net" => NETWORK_APPNET];
q("UPDATE `gcontact` SET `network` = '%s' WHERE `nurl` = '%s'",
dbesc($networks[$urlparts["host"]]), dbesc(normalise_link($user["url"])));
dba::update('gcontact', ['network' => $networks[$urlparts["host"]]],
['nurl' => normalise_link($user["url"])]);
continue;
}
@ -194,8 +195,8 @@ class DiscoverPoCo {
return;
}
} else {
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
dbesc(DateTimeFormat::utcNow()), dbesc(normalise_link($user["url"])));
dba::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
['nurl' => normalise_link($user["url"])]);
}
// Quit the loop after 3 minutes

View File

@ -541,8 +541,8 @@ class Notifier {
if ($push_notify) {
// Set push flag for PuSH subscribers to this topic,
// they will be notified in queue.php
q("UPDATE `push_subscriber` SET `push` = 1 ".
"WHERE `nickname` = '%s' AND `push` = 0", dbesc($owner['nickname']));
$condition = ['push' => false, 'nickname' => $owner['nickname']];
dba::update('push_subscriber', ['push' => true], $condition);
logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);

View File

@ -12,6 +12,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Protocol\OStatus;
use Friendica\Util\Network;
use dba;
require_once 'include/items.php';
@ -76,9 +77,8 @@ class PubSubPublish {
logger('successfully pushed to '.$rr['callback_url']);
// set last_update to the "created" date of the last item, and reset push=0
q("UPDATE `push_subscriber` SET `push` = 0, last_update = '%s' WHERE id = %d",
dbesc($last_update),
intval($rr['id']));
$fields = ['push' => 0, 'last_update' => $last_update];
dba::update('push_subscriber', $fields, ['id' => $rr['id']]);
} else {
logger('error when pushing to '.$rr['callback_url'].' HTTP: '.$ret);
@ -90,9 +90,7 @@ class PubSubPublish {
if ($new_push > 30) // OK, let's give up
$new_push = 0;
q("UPDATE `push_subscriber` SET `push` = %d WHERE id = %d",
$new_push,
intval($rr['id']));
dba::update('push_subscriber', ['push' => $new_push], ['id' => $rr['id']]);
}
}
}

View File

@ -36,7 +36,7 @@ class Queue
// Handling the pubsubhubbub requests
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'PubSubPublish');
$r = dba::inArray(dba::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP()"));
$r = dba::inArray(dba::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
Addon::callHooks('queue_predeliver', $r);

View File

@ -2,6 +2,8 @@
namespace Friendica\Worker;
use dba;
class TagUpdate
{
public static function execute()
@ -13,18 +15,14 @@ class TagUpdate
if ($message['uid'] == 0) {
$global = true;
q("UPDATE `term` SET `global` = 1 WHERE `otype` = %d AND `guid` = '%s'",
intval(TERM_OBJ_POST), dbesc($message['guid']));
dba::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
} else {
$isglobal = q("SELECT `global` FROM `term` WHERE `uid` = 0 AND `otype` = %d AND `guid` = '%s'",
intval(TERM_OBJ_POST), dbesc($message['guid']));
$global = (count($isglobal) > 0);
$global = (dba::count('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]) > 0);
}
q("UPDATE `term` SET `guid` = '%s', `created` = '%s', `received` = '%s', `global` = %d WHERE `otype` = %d AND `oid` = %d",
dbesc($message['guid']), dbesc($message['created']), dbesc($message['received']),
intval($global), intval(TERM_OBJ_POST), intval($message['oid']));
$fields = ['guid' => $message['guid'], 'created' => $message['created'],
'received' => $message['received'], 'global' => $global];
dba::update('term', $fields, ['otype' => TERM_OBJ_POST, 'oid' => $message['oid']]);
}
dba::close($messages);
@ -33,7 +31,7 @@ class TagUpdate
logger('fetched messages: ' . dba::num_rows($messages));
while ($message = dba::fetch(messages)) {
q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($message['guid']));
dba::update('item', ['global' => true], ['guid' => $message['guid']]);
}
dba::close($messages);