]> git.mxchange.org Git - friendica.git/commitdiff
Remove extraneous dba::connect calls
authorHypolite Petovan <mrpetovan@gmail.com>
Tue, 26 Jun 2018 00:56:07 +0000 (20:56 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 16 Jul 2018 23:38:13 +0000 (19:38 -0400)
bin/auth_ejabberd.php
bin/daemon.php
bin/worker.php
index.php
src/Core/Console/ArchiveContact.php
src/Core/Console/Config.php
src/Core/Console/DatabaseStructure.php
src/Core/Console/GlobalCommunityBlock.php
src/Core/Console/GlobalCommunitySilence.php
src/Core/Console/Maintenance.php
src/Core/Console/NewPassword.php

index 10b9d874f1f1825b7a242c107728bd9d218df2ba..6c078e2249dbb016cfa038a10ffafac7035093e3 100755 (executable)
@@ -33,7 +33,6 @@
  */
 
 use Friendica\App;
-use Friendica\Core\Config;
 use Friendica\Util\ExAuth;
 
 if (sizeof($_SERVER["argv"]) == 0) {
@@ -55,10 +54,6 @@ require_once "include/dba.php";
 
 $a = new App(dirname(__DIR__));
 
-@include ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
 $oAuth = new ExAuth();
 
 $oAuth->readStdin();
\ No newline at end of file
index acb4a2c68286296c2f4d6263cb8193e55af15c82..2450e4223e5877532db6eedd8aef09d578220ea7 100755 (executable)
@@ -28,8 +28,9 @@ require_once "include/dba.php";
 
 $a = new App(dirname(__DIR__));
 
-require_once ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
+if ($a->mode === App::MODE_INSTALL) {
+       die("Friendica isn't properly installed yet.\n");
+}
 
 Config::load();
 
@@ -125,11 +126,9 @@ if (!$foreground) {
        file_put_contents($pidfile, $pid);
 
        // We lose the database connection upon forking
-       dba::connect($db_host, $db_user, $db_pass, $db_data);
+       $a->loadDatabase();
 }
 
-unset($db_host, $db_user, $db_pass, $db_data);
-
 Config::set('system', 'worker_daemon_mode', true);
 
 // Just to be sure that this script really runs endlessly
index 77c85b1d58693653ab2e2f84c4b0e9479d85c91c..2abfa0ad9215a71da989c66f6deabe87280d42cd 100755 (executable)
@@ -24,14 +24,9 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
 }
 
 require_once "boot.php";
-require_once "include/dba.php";
 
 $a = new App(dirname(__DIR__));
 
-require_once ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
 Config::load();
 
 // Check the database structure and possibly fixes it
index d83e202d2ac6f125498c1973520aef9340237bf3..501235f4975d07d000e96bc9625fd1f2f75d36b5 100644 (file)
--- a/index.php
+++ b/index.php
@@ -41,10 +41,7 @@ if (!$a->mode == App::MODE_INSTALL) {
 require_once "include/dba.php";
 
 if (!$a->mode == App::MODE_INSTALL) {
-       $result = dba::connect($db_host, $db_user, $db_pass, $db_data);
-       unset($db_host, $db_user, $db_pass, $db_data);
-
-       if (!$result) {
+       if (!dba::connected()) {
                System::unavailable();
        }
 
index 7a973f3116b944aab175fd3ec131bd1294e22e48..63ace91c0f3867ed4b3470de79d722cf785aa48b 100644 (file)
@@ -54,12 +54,8 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               require_once '.htconfig.php';
-               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-               if (!$result) {
-                       throw new \RuntimeException('Unable to connect to database');
+               if ($a->mode === App::MODE_INSTALL) {
+                       throw new \RuntimeException('Friendica isn\'t properly installed yet.');
                }
 
                $nurl = normalise_link($this->getArgument(0));
index 306e1c275eb18af5ab0b667b9da77aabd4a27c22..4f7d090d5c790362ed5bc1c043cc3f41a9b71082 100644 (file)
@@ -92,12 +92,8 @@ HELP;
                        throw new CommandArgsException('Too many arguments');
                }
 
-               require_once '.htconfig.php';
-               $result = dba::connect($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-               if (!$result) {
-                       throw new \RuntimeException('Unable to connect to database');
+               if ($a->mode === \Friendica\App::MODE_INSTALL) {
+                       $this->out('Database isn\'t ready or populated yet, showing file config only');
                }
 
                if (count($this->args) == 3) {
index eb4c6df99837dcf4bac1ded841b8b82ba179007f..11904843102a64aa4e34fd9d6031c1c922c37beb 100644 (file)
@@ -56,11 +56,7 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               require_once '.htconfig.php';
-               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-               if (!$result) {
+               if (!\dba::connected()) {
                        throw new \RuntimeException('Unable to connect to database');
                }
 
index 26c5d13131467bb1d98cb7b9d8956e4360d2aff0..5fcc6be160acaf1686bf9987593efd3c4e95663d 100644 (file)
@@ -56,12 +56,8 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               require_once '.htconfig.php';
-               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-               if (!$result) {
-                       throw new \RuntimeException('Unable to connect to database');
+               if ($a->mode == \Friendica\App::MODE_INSTALL) {
+                       throw new \RuntimeException('Database isn\'t ready or populated yet');
                }
 
                $contact_id = Contact::getIdForURL($this->getArgument(0));
index 72d5a4f88102d70fa003b9b72162fcf03b23bcb5..a70888e4542baebc15aab2ac1676bf743cf8b42e 100644 (file)
@@ -64,12 +64,8 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               require_once '.htconfig.php';
-               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-               if (!$result) {
-                       throw new \RuntimeException('Unable to connect to database');
+               if ($a->mode == \Friendica\App::MODE_INSTALL) {
+                       throw new \RuntimeException('Database isn\'t ready or populated yet');
                }
 
                /**
index 6638e4bfe168c477a2f5349d3506af7825091b6c..68d33337abaef3e8ea19ad35360984a918d725f4 100644 (file)
@@ -64,12 +64,8 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               require_once '.htconfig.php';
-               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-               if (!$result) {
-                       throw new \RuntimeException('Unable to connect to database');
+               if ($a->mode == \Friendica\App::MODE_INSTALL) {
+                       throw new \RuntimeException('Database isn\'t ready or populated yet');
                }
 
                Core\Config::load();
index f5698ba716ff62b1cf0e3258c2155436ca208769..e5f93491905b80fa5f19e95f8f171a771216c9d3 100644 (file)
@@ -58,12 +58,8 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               require_once '.htconfig.php';
-               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-               if (!$result) {
-                       throw new \RuntimeException('Unable to connect to database');
+               if ($a->mode == \Friendica\App::MODE_INSTALL) {
+                       throw new \RuntimeException('Database isn\'t ready or populated yet');
                }
 
                $nick = $this->getArgument(0);