]> git.mxchange.org Git - friendica.git/commitdiff
Refactor deprecated App - process methods to DI::process()->*()
authornupplaPhil <admin@philipp.info>
Sun, 15 Dec 2019 23:33:35 +0000 (00:33 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 29 Dec 2019 19:17:45 +0000 (20:17 +0100)
src/App.php
src/Core/Worker.php
src/DI.php

index 7b0fa07abc93c3446d1c3ec55bd5e77b0ee52377..e213b741a3f3fa85bdb0d26033e705a269171461 100644 (file)
@@ -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
         *
index 9a1570d72fe906de7f6abffbb5d640a5b2ed8ebc..62f7bd4c6ac7609d12bcc84bb11eb28702897e11 100644 (file)
@@ -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;
                }
index 89b638d226df3f99e4c4bf147c32215e1bc55165..c3f6d07f9ce4faf8b18c82fc4cc5752c8a0cfe4a 100644 (file)
@@ -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 */