From decfc553f752fc6c00ad2a965f53ac01833557ad Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 25 Jun 2018 20:44:35 -0400 Subject: [PATCH] Set BaseObject::setApp in App --- bin/auth_ejabberd.php | 4 +--- bin/daemon.php | 2 -- bin/worker.php | 1 - boot.php | 9 +-------- index.php | 2 -- src/App.php | 2 ++ src/BaseObject.php | 8 +++----- 7 files changed, 7 insertions(+), 21 deletions(-) diff --git a/bin/auth_ejabberd.php b/bin/auth_ejabberd.php index 06d8488df8..10b9d874f1 100755 --- a/bin/auth_ejabberd.php +++ b/bin/auth_ejabberd.php @@ -33,7 +33,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Util\ExAuth; @@ -55,7 +54,6 @@ require_once "boot.php"; require_once "include/dba.php"; $a = new App(dirname(__DIR__)); -BaseObject::setApp($a); @include ".htconfig.php"; dba::connect($db_host, $db_user, $db_pass, $db_data); @@ -63,4 +61,4 @@ unset($db_host, $db_user, $db_pass, $db_data); $oAuth = new ExAuth(); -$oAuth->readStdin(); +$oAuth->readStdin(); \ No newline at end of file diff --git a/bin/daemon.php b/bin/daemon.php index 1abb701462..acb4a2c682 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -8,7 +8,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\Worker; @@ -28,7 +27,6 @@ require_once "boot.php"; require_once "include/dba.php"; $a = new App(dirname(__DIR__)); -BaseObject::setApp($a); require_once ".htconfig.php"; dba::connect($db_host, $db_user, $db_pass, $db_data); diff --git a/bin/worker.php b/bin/worker.php index 44980961cf..77c85b1d58 100755 --- a/bin/worker.php +++ b/bin/worker.php @@ -27,7 +27,6 @@ require_once "boot.php"; require_once "include/dba.php"; $a = new App(dirname(__DIR__)); -BaseObject::setApp($a); require_once ".htconfig.php"; dba::connect($db_host, $db_user, $db_pass, $db_data); diff --git a/boot.php b/boot.php index bececa9470..728f36b16e 100644 --- a/boot.php +++ b/boot.php @@ -508,14 +508,7 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) { */ function get_app() { - global $a; - - if (empty($a)) { - $a = new App(dirname(__DIR__)); - BaseObject::setApp($a); - } - - return $a; + return BaseObject::getApp(); } /** diff --git a/index.php b/index.php index d4e263bcc0..d83e202d2a 100644 --- a/index.php +++ b/index.php @@ -9,7 +9,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\Nav; use Friendica\Core\Addon; use Friendica\Core\Config; @@ -25,7 +24,6 @@ use Friendica\Module\Login; require_once 'boot.php'; $a = new App(__DIR__); -BaseObject::setApp($a); // We assume that the index.php is called by a frontend process // The value is set to "true" by default in boot.php diff --git a/src/App.php b/src/App.php index 652b048260..17cfd3eefc 100644 --- a/src/App.php +++ b/src/App.php @@ -139,6 +139,8 @@ class App throw new Exception('Basepath ' . $basepath . ' isn\'t usable.'); } + BaseObject::setApp($this); + $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR); $this->determineUrlPath(); diff --git a/src/BaseObject.php b/src/BaseObject.php index 5adfe096d7..6b64daccf0 100644 --- a/src/BaseObject.php +++ b/src/BaseObject.php @@ -24,12 +24,10 @@ class BaseObject */ public static function getApp() { - if (self::$app) { - return self::$app; + if (empty(self::$app)) { + self::$app = new App(dirname(__DIR__)); } - self::$app = get_app(); - return self::$app; } @@ -40,7 +38,7 @@ class BaseObject * * @return void */ - public static function setApp($app) + public static function setApp(App $app) { self::$app = $app; } -- 2.39.5