diff --git a/mod/item.php b/mod/item.php index b77e725756..8744ba3b2e 100644 --- a/mod/item.php +++ b/mod/item.php @@ -807,12 +807,6 @@ function item_post(App $a) { } } - // Insert an item entry for UID=0 for global entries. - // We now do it in the background to save some time. - // This is important in interactive environments like the frontend or the API. - // We don't fork a new process since this is done anyway with the following command - Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "CreateShadowEntry", $post_id); - // When we are doing some forum posting via ! we have to start the notifier manually. // These kind of posts don't initiate the notifier call in the item class. if ($only_to_forum) { diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 9af219e476..c2fd16f245 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -22,10 +22,8 @@ namespace Friendica\Core; use Friendica\Core; -use Friendica\Core\Process as ProcessAlias; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Model\Process; use Friendica\Util\DateTimeFormat; /** @@ -38,7 +36,7 @@ class Worker const STATE_REFETCH = 3; // Worker had refetched jobs in the execution loop. const STATE_SHORT_LOOP = 4; // Worker is processing preassigned jobs, thus saving much time. - const FAST_COMMANDS = ['APDelivery', 'Delivery', 'CreateShadowEntry']; + const FAST_COMMANDS = ['APDelivery', 'Delivery']; const LOCK_PROCESS = 'worker_process'; const LOCK_WORKER = 'worker'; @@ -580,7 +578,7 @@ class Worker 'workerqueue', ['id', 'pid', 'executed', 'priority', 'parameter'], ['NOT `done` AND `pid` != 0'], - ['order' => ['priority', 'created']] + ['order' => ['priority', 'retrial', 'created']] ); self::$db_duration += (microtime(true) - $stamp); @@ -850,7 +848,7 @@ class Worker $ids = []; $stamp = (float)microtime(true); $condition = ["`priority` = ? AND `pid` = 0 AND NOT `done` AND `next_try` < ?", $priority, DateTimeFormat::utcNow()]; - $tasks = DBA::select('workerqueue', ['id', 'parameter'], $condition, ['limit' => $limit, 'order' => ['created']]); + $tasks = DBA::select('workerqueue', ['id', 'parameter'], $condition, ['limit' => $limit, 'order' => ['retrial', 'created']]); self::$db_duration += (microtime(true) - $stamp); while ($task = DBA::fetch($tasks)) { $ids[] = $task['id']; @@ -970,7 +968,7 @@ class Worker if ($limit > 0) { $stamp = (float)microtime(true); $condition = ["`pid` = 0 AND NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()]; - $tasks = DBA::select('workerqueue', ['id', 'parameter'], $condition, ['limit' => $limit, 'order' => ['priority', 'created']]); + $tasks = DBA::select('workerqueue', ['id', 'parameter'], $condition, ['limit' => $limit, 'order' => ['priority', 'retrial', 'created']]); self::$db_duration += (microtime(true) - $stamp); while ($task = DBA::fetch($tasks)) { @@ -1188,7 +1186,7 @@ class Worker * * next args are passed as $cmd command line * or: Worker::add(PRIORITY_HIGH, "Notifier", Delivery::DELETION, $drop_id); - * or: Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "CreateShadowEntry", $post_id); + * or: Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "Delivery", $post_id); * * @return boolean "false" if worker queue entry already existed or there had been an error * @throws \Friendica\Network\HTTPException\InternalServerErrorException diff --git a/src/Model/Item.php b/src/Model/Item.php index 7b5ddf73e2..aea428cd72 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2325,7 +2325,7 @@ class Item * @param integer $itemid Item ID that should be added * @throws \Exception */ - public static function addShadow($itemid) + private static function addShadow($itemid) { $fields = ['uid', 'private', 'moderated', 'visible', 'deleted', 'network', 'uri']; $condition = ['id' => $itemid, 'parent' => [0, $itemid]]; @@ -2388,7 +2388,7 @@ class Item * @param integer $itemid Item ID that should be added * @throws \Exception */ - public static function addShadowPost($itemid) + private static function addShadowPost($itemid) { $item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]); if (!DBA::isResult($item)) { @@ -2470,6 +2470,10 @@ class Item // Remove possibly remaining links $naked_body = preg_replace(Strings::autoLinkRegEx(), '', $naked_body); + if (empty($naked_body)) { + return ''; + } + $ld = new Language(DI::l10n()->getAvailableLanguages()); $languages = $ld->detect($naked_body)->limit(0, 3)->close(); if (is_array($languages)) { diff --git a/src/Worker/CreateShadowEntry.php b/src/Worker/CreateShadowEntry.php deleted file mode 100644 index bd055f165e..0000000000 --- a/src/Worker/CreateShadowEntry.php +++ /dev/null @@ -1,39 +0,0 @@ -. - * - */ - -namespace Friendica\Worker; - -use Friendica\Model\Item; - -/** - * This script creates posts with UID = 0 for a given public post. - * - * This script is started from mod/item.php to save some time when doing a post. - */ -class CreateShadowEntry { - public static function execute($message_id = 0) { - if (empty($message_id)) { - return; - } - - Item::addShadowPost($message_id); - } -} diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index f861332489..3322616785 100755 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -54,7 +54,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1370); + define('DB_UPDATE_VERSION', 1371); } return [ @@ -1460,7 +1460,7 @@ return [ "PRIMARY" => ["id"], "done_parameter" => ["done", "parameter(64)"], "done_executed" => ["done", "executed"], - "done_priority_created" => ["done", "priority", "created"], + "done_priority_retrial_created" => ["done", "priority", "retrial", "created"], "done_priority_next_try" => ["done", "priority", "next_try"], "done_pid_next_try" => ["done", "pid", "next_try"], "done_pid_retrial" => ["done", "pid", "retrial"],