From 5609e94b0542c3acf1e9851452eaa8c012768f3d Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Mon, 16 Dec 2019 00:33:35 +0100 Subject: [PATCH] Refactor deprecated App - process methods to DI::process()->*() --- src/App.php | 26 -------------------------- src/Core/Worker.php | 12 +++++------- src/DI.php | 3 +++ 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/App.php b/src/App.php index 7b0fa07abc..e213b741a3 100644 --- a/src/App.php +++ b/src/App.php @@ -13,12 +13,10 @@ use Friendica\Core\Config\Cache\ConfigCache; use Friendica\Core\Config\Configuration; use Friendica\Core\Config\PConfiguration; use Friendica\Core\L10n\L10n; -use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Core\Theme; use Friendica\Database\Database; use Friendica\Model\Profile; -use Friendica\Module\Security\Login; use Friendica\Module\Special\HTTPException as ModuleHTTPException; use Friendica\Network\HTTPException; use Friendica\Util\ConfigFileLoader; @@ -356,30 +354,6 @@ class App $this->getBaseURL(); } - /** - * @deprecated 2019.09 - use Core\Process->isMaxProcessesReached() instead - */ - public function isMaxProcessesReached() - { - return $this->process->isMaxProcessesReached(); - } - - /** - * @deprecated 2019.09 - use Core\Process->isMinMemoryReached() instead - */ - public function isMinMemoryReached() - { - return $this->process->isMinMemoryReached(); - } - - /** - * @deprecated 2019.09 - use Core\Process->isMaxLoadReached() instead - */ - public function isMaxLoadReached() - { - return $this->process->isMaxLoadReached(); - } - /** * Generates the site's default sender email address * diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 9a1570d72f..62f7bd4c6a 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -56,7 +56,7 @@ class Worker self::$up_start = microtime(true); // At first check the maximum load. We shouldn't continue with a high load - if ($a->isMaxLoadReached()) { + if (DI::process()->isMaxLoadReached()) { Logger::log('Pre check: maximum load reached, quitting.', Logger::DEBUG); return; } @@ -78,7 +78,7 @@ class Worker } // Do we have too few memory? - if ($a->isMinMemoryReached()) { + if (DI::process()->isMinMemoryReached()) { Logger::log('Pre check: Memory limit reached, quitting.', Logger::DEBUG); return; } @@ -90,7 +90,7 @@ class Worker } // Possibly there are too much database processes that block the system - if ($a->isMaxProcessesReached()) { + if (DI::process()->isMaxProcessesReached()) { Logger::log('Pre check: maximum processes reached, quitting.', Logger::DEBUG); return; } @@ -140,7 +140,7 @@ class Worker } // Check free memory - if ($a->isMinMemoryReached()) { + if (DI::process()->isMinMemoryReached()) { Logger::log('Memory limit reached, quitting.', Logger::DEBUG); Lock::release('worker'); return; @@ -251,8 +251,6 @@ class Worker */ public static function execute($queue) { - $a = \get_app(); - $mypid = getmypid(); // Quit when in maintenance @@ -262,7 +260,7 @@ class Worker } // Constantly check the number of parallel database processes - if ($a->isMaxProcessesReached()) { + if (DI::process()->isMaxProcessesReached()) { Logger::log("Max processes reached for process ".$mypid, Logger::DEBUG); return false; } diff --git a/src/DI.php b/src/DI.php index 89b638d226..c3f6d07f9c 100644 --- a/src/DI.php +++ b/src/DI.php @@ -8,6 +8,7 @@ use Friendica\Core\Config\Configuration; use Friendica\Core\Config\PConfiguration; use Friendica\Core\L10n\L10n; use Friendica\Core\Lock\ILock; +use Friendica\Core\Process; use Friendica\Core\Session\ISession; use Friendica\Database\Database; use Friendica\Model\Notify; @@ -51,6 +52,7 @@ use Psr\Log\LoggerInterface; * @method static App\Router router() * @method static Database dba() * @method static FileSystem fs() + * @method static Process process() * */ class DI @@ -82,6 +84,7 @@ class DI 'dba' => Database::class, 'fs' => FileSystem::class, 'profiler' => Profiler::class, + 'process' => Process::class, ]; /** @var Dice */ -- 2.39.5