Merge branch 'develop' into task/6778-add-storage-move-to-cron
This commit is contained in:
commit
09e03c9213
42 changed files with 1269 additions and 245 deletions
|
@ -266,14 +266,12 @@ class ACL extends BaseObject
|
|||
$default_permissions = self::getDefaultUserPermissions($user);
|
||||
}
|
||||
|
||||
$jotnets = '';
|
||||
$jotnets_fields = [];
|
||||
if ($show_jotnets) {
|
||||
$imap_disabled = !function_exists('imap_open') || Config::get('system', 'imap_disabled');
|
||||
|
||||
$mail_enabled = false;
|
||||
$pubmail_enabled = false;
|
||||
|
||||
if (!$imap_disabled) {
|
||||
if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) {
|
||||
$mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]);
|
||||
if (DBA::isResult($mailacct)) {
|
||||
$mail_enabled = true;
|
||||
|
@ -283,17 +281,20 @@ class ACL extends BaseObject
|
|||
|
||||
if (empty($default_permissions['hidewall'])) {
|
||||
if ($mail_enabled) {
|
||||
$selected = $pubmail_enabled ? ' checked="checked"' : '';
|
||||
$jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> ' . L10n::t("Post to Email") . '</div>';
|
||||
$jotnets_fields[] = [
|
||||
'type' => 'checkbox',
|
||||
'field' => [
|
||||
'pubmail_enable',
|
||||
L10n::t('Post to Email'),
|
||||
$pubmail_enabled
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
Hook::callAll('jot_networks', $jotnets);
|
||||
} else {
|
||||
$jotnets .= L10n::t('Connectors disabled, since "%s" is enabled.',
|
||||
L10n::t('Hide your profile details from unknown viewers?'));
|
||||
Hook::callAll('jot_networks', $jotnets_fields);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('acl_selector.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$showall' => L10n::t('Visible to everybody'),
|
||||
|
@ -306,7 +307,10 @@ class ACL extends BaseObject
|
|||
'$networks' => $show_jotnets,
|
||||
'$emailcc' => L10n::t('CC: email addresses'),
|
||||
'$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
|
||||
'$jotnets' => $jotnets,
|
||||
'$jotnets_enabled' => empty($default_permissions['hidewall']),
|
||||
'$jotnets_summary' => L10n::t('Connectors'),
|
||||
'$jotnets_fields' => $jotnets_fields,
|
||||
'$jotnets_disabled_label' => L10n::t('Connectors disabled, since "%s" is enabled.', L10n::t('Hide your profile details from unknown viewers?')),
|
||||
'$aclModalTitle' => L10n::t('Permissions'),
|
||||
'$aclModalDismiss' => L10n::t('Close'),
|
||||
'$features' => [
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Friendica\Core\Config\Cache;
|
|||
/**
|
||||
* The Friendica config cache for the application
|
||||
* Initial, all *.config.php files are loaded into this cache with the
|
||||
* ConfigCacheLoader ( @see ConfigCacheLoader )
|
||||
* ConfigFileLoader ( @see ConfigFileLoader )
|
||||
*/
|
||||
class ConfigCache implements IConfigCache, IPConfigCache
|
||||
{
|
||||
|
|
|
@ -1,231 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Core\Config\Cache;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
|
||||
/**
|
||||
* The ConfigCacheLoader loads config-files and stores them in a ConfigCache ( @see ConfigCache )
|
||||
*
|
||||
* It is capable of loading the following config files:
|
||||
* - *.config.php (current)
|
||||
* - *.ini.php (deprecated)
|
||||
* - *.htconfig.php (deprecated)
|
||||
*/
|
||||
class ConfigCacheLoader
|
||||
{
|
||||
/**
|
||||
* The Sub directory of the config-files
|
||||
* @var string
|
||||
*/
|
||||
const SUBDIRECTORY = 'config';
|
||||
|
||||
private $baseDir;
|
||||
private $configDir;
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
|
||||
public function __construct($baseDir, App\Mode $mode)
|
||||
{
|
||||
$this->appMode = $mode;
|
||||
$this->baseDir = $baseDir;
|
||||
$this->configDir = $baseDir . DIRECTORY_SEPARATOR . self::SUBDIRECTORY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration files
|
||||
*
|
||||
* First loads the default value for all the configuration keys, then the legacy configuration files, then the
|
||||
* expected local.config.php
|
||||
*
|
||||
* @param IConfigCache The config cache to load to
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function loadConfigFiles(IConfigCache $config)
|
||||
{
|
||||
$config->load($this->loadCoreConfig('defaults'));
|
||||
$config->load($this->loadCoreConfig('settings'));
|
||||
|
||||
$config->load($this->loadLegacyConfig('htpreconfig'), true);
|
||||
$config->load($this->loadLegacyConfig('htconfig'), true);
|
||||
|
||||
$config->load($this->loadCoreConfig('local'), true);
|
||||
|
||||
// In case of install mode, add the found basepath (because there isn't a basepath set yet
|
||||
if ($this->appMode->isInstall()) {
|
||||
// Setting at least the basepath we know
|
||||
$config->set('system', 'basepath', $this->baseDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the specified core-configuration and returns the config array.
|
||||
*
|
||||
* @param string $name The name of the configuration
|
||||
*
|
||||
* @return array The config array (empty if no config found)
|
||||
*
|
||||
* @throws \Exception if the configuration file isn't readable
|
||||
*/
|
||||
public function loadCoreConfig($name)
|
||||
{
|
||||
if (file_exists($this->configDir . DIRECTORY_SEPARATOR . $name . '.config.php')) {
|
||||
return $this->loadConfigFile($this->configDir . DIRECTORY_SEPARATOR . $name . '.config.php');
|
||||
} elseif (file_exists($this->configDir . DIRECTORY_SEPARATOR . $name . '.ini.php')) {
|
||||
return $this->loadINIConfigFile($this->configDir . DIRECTORY_SEPARATOR . $name . '.ini.php');
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the specified addon-configuration and returns the config array.
|
||||
*
|
||||
* @param string $name The name of the configuration
|
||||
*
|
||||
* @return array The config array (empty if no config found)
|
||||
*
|
||||
* @throws \Exception if the configuration file isn't readable
|
||||
*/
|
||||
public function loadAddonConfig($name)
|
||||
{
|
||||
$filepath = $this->baseDir . DIRECTORY_SEPARATOR . // /var/www/html/
|
||||
Addon::DIRECTORY . DIRECTORY_SEPARATOR . // addon/
|
||||
$name . DIRECTORY_SEPARATOR . // openstreetmap/
|
||||
self::SUBDIRECTORY . DIRECTORY_SEPARATOR . // config/
|
||||
$name . ".config.php"; // openstreetmap.config.php
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
return $this->loadConfigFile($filepath);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the legacy config files (.htconfig.php, .htpreconfig.php) and returns the config array.
|
||||
*
|
||||
* @param string $name The name of the config file
|
||||
*
|
||||
* @return array The configuration array (empty if no config found)
|
||||
*
|
||||
* @deprecated since version 2018.09
|
||||
*/
|
||||
private function loadLegacyConfig($name)
|
||||
{
|
||||
$filePath = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php';
|
||||
|
||||
$config = [];
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
$a = new \stdClass();
|
||||
$a->config = [];
|
||||
include $filePath;
|
||||
|
||||
$htConfigCategories = array_keys($a->config);
|
||||
|
||||
// map the legacy configuration structure to the current structure
|
||||
foreach ($htConfigCategories as $htConfigCategory) {
|
||||
if (is_array($a->config[$htConfigCategory])) {
|
||||
$keys = array_keys($a->config[$htConfigCategory]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$config[$htConfigCategory][$key] = $a->config[$htConfigCategory][$key];
|
||||
}
|
||||
} else {
|
||||
$config['config'][$htConfigCategory] = $a->config[$htConfigCategory];
|
||||
}
|
||||
}
|
||||
|
||||
unset($a);
|
||||
|
||||
if (isset($db_host)) {
|
||||
$config['database']['hostname'] = $db_host;
|
||||
unset($db_host);
|
||||
}
|
||||
if (isset($db_user)) {
|
||||
$config['database']['username'] = $db_user;
|
||||
unset($db_user);
|
||||
}
|
||||
if (isset($db_pass)) {
|
||||
$config['database']['password'] = $db_pass;
|
||||
unset($db_pass);
|
||||
}
|
||||
if (isset($db_data)) {
|
||||
$config['database']['database'] = $db_data;
|
||||
unset($db_data);
|
||||
}
|
||||
if (isset($config['system']['db_charset'])) {
|
||||
$config['database']['charset'] = $config['system']['db_charset'];
|
||||
}
|
||||
if (isset($pidfile)) {
|
||||
$config['system']['pidfile'] = $pidfile;
|
||||
unset($pidfile);
|
||||
}
|
||||
if (isset($default_timezone)) {
|
||||
$config['system']['default_timezone'] = $default_timezone;
|
||||
unset($default_timezone);
|
||||
}
|
||||
if (isset($lang)) {
|
||||
$config['system']['language'] = $lang;
|
||||
unset($lang);
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the specified legacy configuration file and returns the config array.
|
||||
*
|
||||
* @deprecated since version 2018.12
|
||||
* @param string $filepath
|
||||
*
|
||||
* @return array The configuration array
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function loadINIConfigFile($filepath)
|
||||
{
|
||||
$contents = include($filepath);
|
||||
|
||||
$config = parse_ini_string($contents, true, INI_SCANNER_TYPED);
|
||||
|
||||
if ($config === false) {
|
||||
throw new \Exception('Error parsing INI config file ' . $filepath);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the specified configuration file and returns the config array.
|
||||
*
|
||||
* The config format is PHP array and the template for configuration files is the following:
|
||||
*
|
||||
* <?php return [
|
||||
* 'section' => [
|
||||
* 'key' => 'value',
|
||||
* ],
|
||||
* ];
|
||||
*
|
||||
* @param string $filepath The filepath of the
|
||||
* @return array The config array0
|
||||
*
|
||||
* @throws \Exception if the config cannot get loaded.
|
||||
*/
|
||||
private function loadConfigFile($filepath)
|
||||
{
|
||||
$config = include($filepath);
|
||||
|
||||
if (!is_array($config)) {
|
||||
throw new \Exception('Error loading config file ' . $filepath);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,16 @@ namespace Friendica\Core\Config;
|
|||
*/
|
||||
class Configuration
|
||||
{
|
||||
/**
|
||||
* The blacklist of configuration settings, which should not get saved to the backend
|
||||
* @var array
|
||||
*/
|
||||
private $configSaveBlacklist = [
|
||||
'config' => [
|
||||
'hostname' => true,
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* @var Cache\IConfigCache
|
||||
*/
|
||||
|
@ -117,7 +127,7 @@ class Configuration
|
|||
$cached = $this->configCache->set($cat, $key, $value);
|
||||
|
||||
// If there is no connected adapter, we're finished
|
||||
if (!$this->configAdapter->isConnected()) {
|
||||
if (!$this->configAdapter->isConnected() || !empty($this->configSaveBlacklist[$cat][$key])) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use Friendica\BaseObject;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Installer;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Util\Config\ConfigFileLoader;
|
||||
use RuntimeException;
|
||||
|
||||
class AutomaticInstallation extends Console
|
||||
|
@ -103,8 +104,8 @@ HELP;
|
|||
}
|
||||
|
||||
//reload the config cache
|
||||
$loader = new Config\Cache\ConfigCacheLoader($a->getBasePath(), $a->getMode());
|
||||
$loader->loadConfigFiles($configCache);
|
||||
$loader = new ConfigFileLoader($a->getBasePath(), $a->getMode());
|
||||
$loader->setupCache($configCache);
|
||||
|
||||
} else {
|
||||
// Creating config file
|
||||
|
|
|
@ -108,7 +108,13 @@ class NotificationsManager extends BaseObject
|
|||
*/
|
||||
public function setSeen($note, $seen = true)
|
||||
{
|
||||
return DBA::update('notify', ['seen' => $seen], ['link' => $note['link'], 'parent' => $note['parent'], 'otype' => $note['otype'], 'uid' => local_user()]);
|
||||
return DBA::update('notify', ['seen' => $seen], [
|
||||
'(`link` = ? OR (`parent` != 0 AND `parent` = ? AND `otype` = ?)) AND `uid` = ?',
|
||||
$note['link'],
|
||||
$note['parent'],
|
||||
$note['otype'],
|
||||
local_user()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -557,7 +563,7 @@ class NotificationsManager extends BaseObject
|
|||
$sql_extra = "";
|
||||
|
||||
if (!$all) {
|
||||
$sql_extra = " AND `ignore` = 0 ";
|
||||
$sql_extra = " AND NOT `ignore` ";
|
||||
}
|
||||
|
||||
/// @todo Fetch contact details by "Contact::getDetailsByUrl" instead of queries to contact, fcontact and gcontact
|
||||
|
@ -572,11 +578,11 @@ class NotificationsManager extends BaseObject
|
|||
LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id`
|
||||
LEFT JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
|
||||
LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
|
||||
WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0
|
||||
LIMIT %d, %d",
|
||||
intval($_SESSION['uid']),
|
||||
intval($start),
|
||||
intval($limit)
|
||||
WHERE `intro`.`uid` = ? $sql_extra AND `intro`.`blocked` = 0
|
||||
LIMIT ?, ?",
|
||||
$_SESSION['uid'],
|
||||
$start,
|
||||
$limit
|
||||
);
|
||||
if (DBA::isResult($stmtNotifies)) {
|
||||
$notifs = $this->formatIntros(DBA::toArray($stmtNotifies));
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Util\BasePath;
|
||||
use Friendica\Util\Config\ConfigFileLoader;
|
||||
use Friendica\Util\Config\ConfigFileSaver;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
class Update
|
||||
|
@ -24,6 +29,11 @@ class Update
|
|||
return;
|
||||
}
|
||||
|
||||
// Don't check the status if the last update was failed
|
||||
if (Config::get('system', 'update', Update::SUCCESS, true) == Update::FAILED) {
|
||||
return;
|
||||
}
|
||||
|
||||
$build = Config::get('system', 'build');
|
||||
|
||||
if (empty($build)) {
|
||||
|
@ -101,7 +111,9 @@ class Update
|
|||
for ($x = $stored + 1; $x <= $current; $x++) {
|
||||
$r = self::runUpdateFunction($x, 'pre_update');
|
||||
if (!$r) {
|
||||
break;
|
||||
Config::set('system', 'update', Update::FAILED);
|
||||
Lock::release('dbupdate');
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,6 +127,7 @@ class Update
|
|||
);
|
||||
}
|
||||
Logger::error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
|
||||
Config::set('system', 'update', Update::FAILED);
|
||||
Lock::release('dbupdate');
|
||||
return $retval;
|
||||
} else {
|
||||
|
@ -127,7 +140,9 @@ class Update
|
|||
for ($x = $stored + 1; $x <= $current; $x++) {
|
||||
$r = self::runUpdateFunction($x, 'update');
|
||||
if (!$r) {
|
||||
break;
|
||||
Config::set('system', 'update', Update::FAILED);
|
||||
Lock::release('dbupdate');
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,6 +151,7 @@ class Update
|
|||
self::updateSuccessfull($stored, $current);
|
||||
}
|
||||
|
||||
Config::set('system', 'update', Update::SUCCESS);
|
||||
Lock::release('dbupdate');
|
||||
}
|
||||
}
|
||||
|
@ -208,6 +224,93 @@ class Update
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the config settings and saves given config values into the config file
|
||||
*
|
||||
* @param string $basePath The basepath of Friendica
|
||||
* @param App\Mode $mode The Application mode
|
||||
*
|
||||
* @return bool True, if something has been saved
|
||||
*/
|
||||
public static function saveConfigToFile($basePath, App\Mode $mode)
|
||||
{
|
||||
$configFileLoader = new ConfigFileLoader($basePath, $mode);
|
||||
$configCache = new Config\Cache\ConfigCache();
|
||||
$configFileLoader->setupCache($configCache, true);
|
||||
$configFileSaver = new ConfigFileSaver($basePath);
|
||||
|
||||
$updated = false;
|
||||
|
||||
if (self::updateConfigEntry($configCache, $configFileSaver,'config', 'hostname')) {
|
||||
$updated = true;
|
||||
};
|
||||
|
||||
if (self::updateConfigEntry($configCache, $configFileSaver,'system', 'basepath', BasePath::create(dirname(__DIR__) . '/../'))) {
|
||||
$updated = true;
|
||||
}
|
||||
|
||||
// In case there is nothing to do, skip the update
|
||||
if (!$updated) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$configFileSaver->saveToConfigFile()) {
|
||||
Logger::alert('Config entry update failed - maybe wrong permission?');
|
||||
return false;
|
||||
}
|
||||
|
||||
DBA::delete('config', ['cat' => 'config', 'k' => 'hostname']);
|
||||
DBA::delete('config', ['cat' => 'system', 'k' => 'basepath']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value to the ConfigFileSave in case it isn't already updated
|
||||
*
|
||||
* @param IConfigCache $configCache The cached config file
|
||||
* @param ConfigFileSaver $configFileSaver The config file saver
|
||||
* @param string $cat The config category
|
||||
* @param string $key The config key
|
||||
* @param string $default A default value, if none of the settings are valid
|
||||
*
|
||||
* @return boolean True, if a value was updated
|
||||
*
|
||||
* @throws \Exception if DBA or Logger doesn't work
|
||||
*/
|
||||
private static function updateConfigEntry(IConfigCache $configCache, ConfigFileSaver $configFileSaver, $cat, $key, $default = '')
|
||||
{
|
||||
// check if the config file differs from the whole configuration (= The db contains other values)
|
||||
$fileConfig = $configCache->get($cat, $key);
|
||||
|
||||
$savedConfig = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $key]);
|
||||
|
||||
if (DBA::isResult($savedConfig)) {
|
||||
$savedValue = $savedConfig['v'];
|
||||
} else {
|
||||
$savedValue = null;
|
||||
}
|
||||
|
||||
// If the db contains a config value, check it
|
||||
if (isset($savedValue) && $fileConfig !== $savedValue) {
|
||||
Logger::info('Difference in config found', ['cat' => $cat, 'key' => $key, 'file' => $fileConfig, 'saved' => $savedValue]);
|
||||
$configFileSaver->addConfigValue($cat, $key, $savedValue);
|
||||
return true;
|
||||
|
||||
// If both config values are not set, use the default value
|
||||
} elseif (!isset($fileConfig) && !isset($savedValue)) {
|
||||
Logger::info('Using default for config', ['cat' => $cat, 'key' => $key, 'value' => $default]);
|
||||
$configFileSaver->addConfigValue($cat, $key, $default);
|
||||
return true;
|
||||
|
||||
// If either the file config value isn't empty or the db value is the same as the
|
||||
// file config value, skip it
|
||||
} else {
|
||||
Logger::info('No Difference in config found', ['cat' => $cat, 'key' => $key, 'value' => $fileConfig, 'saved' => $savedValue]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* send the email and do what is needed to do on update fails
|
||||
*
|
||||
|
|
|
@ -27,6 +27,9 @@ 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'];
|
||||
|
||||
|
||||
private static $up_start;
|
||||
private static $db_duration = 0;
|
||||
private static $db_duration_count = 0;
|
||||
|
@ -783,23 +786,24 @@ class Worker
|
|||
return [];
|
||||
}
|
||||
|
||||
if ($priority <= PRIORITY_MEDIUM) {
|
||||
$limit = Config::get('system', 'worker_fetch_limit', 1);
|
||||
} else {
|
||||
$limit = 1;
|
||||
}
|
||||
$limit = Config::get('system', 'worker_fetch_limit', 1);
|
||||
|
||||
$ids = [];
|
||||
$stamp = (float)microtime(true);
|
||||
$condition = ["`priority` = ? AND `pid` = 0 AND NOT `done` AND `next_try` < ?", $priority, DateTimeFormat::utcNow()];
|
||||
$tasks = DBA::select('workerqueue', ['id'], $condition, ['limit' => $limit, 'order' => ['created']]);
|
||||
$tasks = DBA::select('workerqueue', ['id', 'parameter'], $condition, ['limit' => $limit, 'order' => ['created']]);
|
||||
self::$db_duration += (microtime(true) - $stamp);
|
||||
while ($task = DBA::fetch($tasks)) {
|
||||
$ids[] = $task['id'];
|
||||
// Only continue that loop while we are storing commands that can be processed quickly
|
||||
$command = json_decode($task['parameter'])[0];
|
||||
if (!in_array($command, self::FAST_COMMANDS)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
DBA::close($tasks);
|
||||
|
||||
Logger::info('Found:', ['id' => $ids, 'priority' => $priority]);
|
||||
Logger::info('Found:', ['priority' => $priority, 'id' => $ids]);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
|
@ -890,15 +894,22 @@ class Worker
|
|||
|
||||
// If there is no result we check without priority limit
|
||||
if (empty($ids)) {
|
||||
$limit = Config::get('system', 'worker_fetch_limit', 1);
|
||||
|
||||
$stamp = (float)microtime(true);
|
||||
$condition = ["`pid` = 0 AND NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];
|
||||
$result = DBA::select('workerqueue', ['id'], $condition, ['limit' => 1, 'order' => ['priority', 'created']]);
|
||||
$tasks = DBA::select('workerqueue', ['id', 'parameter'], $condition, ['limit' => $limit, 'order' => ['priority', 'created']]);
|
||||
self::$db_duration += (microtime(true) - $stamp);
|
||||
|
||||
while ($id = DBA::fetch($result)) {
|
||||
$ids[] = $id["id"];
|
||||
while ($task = DBA::fetch($tasks)) {
|
||||
$ids[] = $task['id'];
|
||||
// Only continue that loop while we are storing commands that can be processed quickly
|
||||
$command = json_decode($task['parameter'])[0];
|
||||
if (!in_array($command, self::FAST_COMMANDS)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
DBA::close($result);
|
||||
DBA::close($tasks);
|
||||
}
|
||||
|
||||
if (!empty($ids)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue