*/
private static function execFunction(array $queue, string $funcname, array $argv, bool $method_call)
{
- $a = DI::app();
+ $appHelper = DI::apphelper();
self::coolDown();
// For this reason the variables have to be initialized.
DI::profiler()->reset();
- $a->setQueue($queue);
+ $appHelper->setQueue($queue);
$up_duration = microtime(true) - self::$up_start;
Logger::disableWorker();
- $a->setQueue([]);
+ $appHelper->setQueue([]);
$duration = (microtime(true) - $stamp);
return false;
} elseif ($max_idletime > 0) {
Logger::debug('Maximum idletime not reached.', ['last' => $last_check, 'last-check' => $last_date, 'seconds' => $max_idletime, 'load' => $load, 'max_load' => $maxsysload, 'active_worker' => $active, 'max_worker' => $maxqueues]);
- }
+ }
}
}
*/
public static function getRetrial(): int
{
- $queue = DI::app()->getQueue();
+ $queue = DI::apphelper()->getQueue();
return $queue['retrial'] ?? 0;
}
/**
* Defers the current worker entry
*
- * @param int $worker_defer_limit Maximum defer limit
+ * @param int $worker_defer_limit Maximum defer limit
* @return boolean had the entry been deferred?
* @throws \Exception
*/
public static function defer(int $worker_defer_limit = 0): bool
{
- $queue = DI::app()->getQueue();
+ $queue = DI::apphelper()->getQueue();
if (empty($queue)) {
return false;
{
public static function execute($param = '', $hook_function = '')
{
- $a = DI::app();
+ $appHelper = DI::apphelper();
Hook::loadHooks();
$r = DBA::select('user', ['uid', 'username'], ["`expire` != ?", 0]);
while ($row = DBA::fetch($r)) {
Logger::info('Calling expiry', ['user' => $row['uid'], 'username' => $row['username']]);
- Worker::add(['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
+ Worker::add(['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
'Expire', (int)$row['uid']);
}
DBA::close($r);
Logger::notice('calling hooks');
foreach (Hook::getByName('expire') as $hook) {
Logger::info('Calling expire', ['hook' => $hook[1]]);
- Worker::add(['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
+ Worker::add(['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
'Expire', 'hook', $hook[1]);
}
{
public static function execute(string $cmd, int $post_uriid, int $sender_uid = 0)
{
- $a = DI::app();
+ $appHelper = DI::apphelper();
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]);
foreach ($inboxes as $inbox => $receivers) {
$ap_contacts = array_merge($ap_contacts, $receivers);
Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'target' => $target_id, 'inbox' => $inbox]);
- Worker::add(['priority' => Worker::PRIORITY_HIGH, 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
+ Worker::add(['priority' => Worker::PRIORITY_HIGH, 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid);
}
} elseif ($cmd == Delivery::SUGGESTION) {
$uid = $suggest->uid;
$recipients[] = $suggest->cid;
} elseif ($cmd == Delivery::REMOVAL) {
- return self::notifySelfRemoval($target_id, $a->getQueueValue('priority'), $a->getQueueValue('created'));
+ return self::notifySelfRemoval($target_id, $appHelper->getQueueValue('priority'), $appHelper->getQueueValue('created'));
} elseif ($cmd == Delivery::RELOCATION) {
$uid = $target_id;
Logger::info('Got post', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'network' => $target_item['network'], 'parent-network' => $parent['network'], 'thread-parent-network' => $thr_parent['network']]);
if (!self::isRemovalActivity($cmd, $owner, Protocol::ACTIVITYPUB)) {
- $apdelivery = self::activityPubDelivery($cmd, $target_item, $parent, $thr_parent, $a->getQueueValue('priority'), $a->getQueueValue('created'), $owner);
+ $apdelivery = self::activityPubDelivery($cmd, $target_item, $parent, $thr_parent, $appHelper->getQueueValue('priority'), $appHelper->getQueueValue('created'), $owner);
$ap_contacts = $apdelivery['contacts'];
$delivery_queue_count += $apdelivery['count'];
// Restrict distribution to AP, when there are no permissions.
if (!empty($target_item)) {
Logger::info('Calling hooks for ' . $cmd . ' ' . $target_id);
- Hook::fork($a->getQueueValue('priority'), 'notifier_normal', $target_item);
+ Hook::fork($appHelper->getQueueValue('priority'), 'notifier_normal', $target_item);
Hook::callAll('notifier_end', $target_item);
*/
private static function delivery(string $cmd, int $post_uriid, int $sender_uid, array $target_item, array $thr_parent, array $owner, bool $batch_delivery, bool $in_batch, array $contacts, array $ap_contacts, array $conversants = []): int
{
- $a = DI::app();
+ $appHelper = DI::apphelper();
$delivery_queue_count = 0;
if (!empty($target_item['verb']) && ($target_item['verb'] == Activity::ANNOUNCE)) {
// Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.
// The conversion in Markdown reduces the formatting, so these posts should arrive after the Friendica posts.
// This is only important for high and medium priority tasks and not for Low priority jobs like deletions.
- if (($contact['network'] == Protocol::DIASPORA) && in_array($a->getQueueValue('priority'), [Worker::PRIORITY_HIGH, Worker::PRIORITY_MEDIUM])) {
- $deliver_options = ['priority' => $a->getQueueValue('priority'), 'dont_fork' => true];
+ if (($contact['network'] == Protocol::DIASPORA) && in_array($appHelper->getQueueValue('priority'), [Worker::PRIORITY_HIGH, Worker::PRIORITY_MEDIUM])) {
+ $deliver_options = ['priority' => $appHelper->getQueueValue('priority'), 'dont_fork' => true];
} else {
- $deliver_options = ['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true];
+ $deliver_options = ['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true];
}
if (!empty($contact['gsid']) && DI::config()->get('system', 'bulk_delivery')) {