}
}
- // 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) {
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;
/**
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';
'workerqueue',
['id', 'pid', 'executed', 'priority', 'parameter'],
['NOT `done` AND `pid` != 0'],
- ['order' => ['priority', 'created']]
+ ['order' => ['priority', 'retrial', 'created']]
);
self::$db_duration += (microtime(true) - $stamp);
$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'];
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)) {
*
* 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
* @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]];
* @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)) {
// 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)) {
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2020, Friendica
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-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);
- }
-}
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1370);
+ define('DB_UPDATE_VERSION', 1371);
}
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"],