Merge pull request #9638 from annando/bad-priority
Check for bad worker priorities
This commit is contained in:
commit
9c0342b907
1
boot.php
1
boot.php
|
@ -201,6 +201,7 @@ define('PRIORITY_HIGH', 20);
|
||||||
define('PRIORITY_MEDIUM', 30);
|
define('PRIORITY_MEDIUM', 30);
|
||||||
define('PRIORITY_LOW', 40);
|
define('PRIORITY_LOW', 40);
|
||||||
define('PRIORITY_NEGLIGIBLE', 50);
|
define('PRIORITY_NEGLIGIBLE', 50);
|
||||||
|
define('PRIORITIES', [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE]);
|
||||||
/* @}*/
|
/* @}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -421,6 +421,11 @@ class Worker
|
||||||
// For this reason the variables have to be initialized.
|
// For this reason the variables have to be initialized.
|
||||||
DI::profiler()->reset();
|
DI::profiler()->reset();
|
||||||
|
|
||||||
|
if (!in_array($queue['priority'], PRIORITIES)) {
|
||||||
|
Logger::warning('Invalid priority', ['queue' => $queue, 'callstack' => System::callstack(20)]);
|
||||||
|
$queue['priority'] = PRIORITY_MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
$a->queue = $queue;
|
$a->queue = $queue;
|
||||||
|
|
||||||
$up_duration = microtime(true) - self::$up_start;
|
$up_duration = microtime(true) - self::$up_start;
|
||||||
|
@ -1264,6 +1269,11 @@ class Worker
|
||||||
$found = DBA::exists('workerqueue', ['command' => $command, 'parameter' => $parameters, 'done' => false]);
|
$found = DBA::exists('workerqueue', ['command' => $command, 'parameter' => $parameters, 'done' => false]);
|
||||||
$added = false;
|
$added = false;
|
||||||
|
|
||||||
|
if (!in_array($priority, PRIORITIES)) {
|
||||||
|
Logger::warning('Invalid priority', ['priority' => $priority, 'command' => $command, 'callstack' => System::callstack(20)]);
|
||||||
|
$priority = PRIORITY_MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
// Quit if there was a database error - a precaution for the update process to 3.5.3
|
// Quit if there was a database error - a precaution for the update process to 3.5.3
|
||||||
if (DBA::errorNo() != 0) {
|
if (DBA::errorNo() != 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1568,7 +1568,7 @@ class Item
|
||||||
$item['network'] = Protocol::DFRN;
|
$item['network'] = Protocol::DFRN;
|
||||||
$item['protocol'] = Conversation::PARCEL_DIRECT;
|
$item['protocol'] = Conversation::PARCEL_DIRECT;
|
||||||
|
|
||||||
if (is_int($notify)) {
|
if (in_array($notify, PRIORITIES)) {
|
||||||
$priority = $notify;
|
$priority = $notify;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2912,7 +2912,7 @@ class Item
|
||||||
$_SESSION["authenticated"] = true;
|
$_SESSION["authenticated"] = true;
|
||||||
$_SESSION["uid"] = $contact['uid'];
|
$_SESSION["uid"] = $contact['uid'];
|
||||||
|
|
||||||
return $result;
|
return (bool)$result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -623,7 +623,7 @@ class Feed
|
||||||
'taglist' => $taglist, 'attachments' => $attachments];
|
'taglist' => $taglist, 'attachments' => $attachments];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger::info('Post already crated or exists in the delayed posts queue', ['uid' => $item['uid'], 'uri' => $item["uri"]]);
|
Logger::info('Post already created or exists in the delayed posts queue', ['uid' => $item['uid'], 'uri' => $item["uri"]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,7 @@
|
||||||
namespace Friendica\Worker;
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Model\Item;
|
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
|
||||||
|
|
||||||
class DelayedPublish
|
class DelayedPublish
|
||||||
{
|
{
|
||||||
|
@ -40,6 +38,6 @@ class DelayedPublish
|
||||||
public static function execute(array $item, int $notify = 0, array $taglist = [], array $attachments = [])
|
public static function execute(array $item, int $notify = 0, array $taglist = [], array $attachments = [])
|
||||||
{
|
{
|
||||||
$id = Post\Delayed::publish($item, $notify, $taglist, $attachments);
|
$id = Post\Delayed::publish($item, $notify, $taglist, $attachments);
|
||||||
Logger::notice('Post published', ['id' => $id, 'uid' => $item['uid'], 'cid' => $item['contact-id']]);
|
Logger::notice('Post published', ['id' => $id, 'uid' => $item['uid'], 'cid' => $item['contact-id'], 'notify' => $notify]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user