Browse Source

Remove extraneous dba::connect calls

tags/2018.09
Hypolite Petovan 1 year ago
parent
commit
3985a4bc43

+ 0
- 5
bin/auth_ejabberd.php View File

@@ -33,7 +33,6 @@
33 33
  */
34 34
 
35 35
 use Friendica\App;
36
-use Friendica\Core\Config;
37 36
 use Friendica\Util\ExAuth;
38 37
 
39 38
 if (sizeof($_SERVER["argv"]) == 0) {
@@ -55,10 +54,6 @@ require_once "include/dba.php";
55 54
 
56 55
 $a = new App(dirname(__DIR__));
57 56
 
58
-@include ".htconfig.php";
59
-dba::connect($db_host, $db_user, $db_pass, $db_data);
60
-unset($db_host, $db_user, $db_pass, $db_data);
61
-
62 57
 $oAuth = new ExAuth();
63 58
 
64 59
 $oAuth->readStdin();

+ 4
- 5
bin/daemon.php View File

@@ -28,8 +28,9 @@ require_once "include/dba.php";
28 28
 
29 29
 $a = new App(dirname(__DIR__));
30 30
 
31
-require_once ".htconfig.php";
32
-dba::connect($db_host, $db_user, $db_pass, $db_data);
31
+if ($a->mode === App::MODE_INSTALL) {
32
+	die("Friendica isn't properly installed yet.\n");
33
+}
33 34
 
34 35
 Config::load();
35 36
 
@@ -125,11 +126,9 @@ if (!$foreground) {
125 126
 	file_put_contents($pidfile, $pid);
126 127
 
127 128
 	// We lose the database connection upon forking
128
-	dba::connect($db_host, $db_user, $db_pass, $db_data);
129
+	$a->loadDatabase();
129 130
 }
130 131
 
131
-unset($db_host, $db_user, $db_pass, $db_data);
132
-
133 132
 Config::set('system', 'worker_daemon_mode', true);
134 133
 
135 134
 // Just to be sure that this script really runs endlessly

+ 0
- 5
bin/worker.php View File

@@ -24,14 +24,9 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
24 24
 }
25 25
 
26 26
 require_once "boot.php";
27
-require_once "include/dba.php";
28 27
 
29 28
 $a = new App(dirname(__DIR__));
30 29
 
31
-require_once ".htconfig.php";
32
-dba::connect($db_host, $db_user, $db_pass, $db_data);
33
-unset($db_host, $db_user, $db_pass, $db_data);
34
-
35 30
 Config::load();
36 31
 
37 32
 // Check the database structure and possibly fixes it

+ 1
- 4
index.php View File

@@ -41,10 +41,7 @@ if (!$a->mode == App::MODE_INSTALL) {
41 41
 require_once "include/dba.php";
42 42
 
43 43
 if (!$a->mode == App::MODE_INSTALL) {
44
-	$result = dba::connect($db_host, $db_user, $db_pass, $db_data);
45
-	unset($db_host, $db_user, $db_pass, $db_data);
46
-
47
-	if (!$result) {
44
+	if (!dba::connected()) {
48 45
 		System::unavailable();
49 46
 	}
50 47
 

+ 2
- 6
src/Core/Console/ArchiveContact.php View File

@@ -54,12 +54,8 @@ HELP;
54 54
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
55 55
 		}
56 56
 
57
-		require_once '.htconfig.php';
58
-		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
59
-		unset($db_host, $db_user, $db_pass, $db_data);
60
-
61
-		if (!$result) {
62
-			throw new \RuntimeException('Unable to connect to database');
57
+		if ($a->mode === App::MODE_INSTALL) {
58
+			throw new \RuntimeException('Friendica isn\'t properly installed yet.');
63 59
 		}
64 60
 
65 61
 		$nurl = normalise_link($this->getArgument(0));

+ 2
- 6
src/Core/Console/Config.php View File

@@ -92,12 +92,8 @@ HELP;
92 92
 			throw new CommandArgsException('Too many arguments');
93 93
 		}
94 94
 
95
-		require_once '.htconfig.php';
96
-		$result = dba::connect($db_host, $db_user, $db_pass, $db_data);
97
-		unset($db_host, $db_user, $db_pass, $db_data);
98
-
99
-		if (!$result) {
100
-			throw new \RuntimeException('Unable to connect to database');
95
+		if ($a->mode === \Friendica\App::MODE_INSTALL) {
96
+			$this->out('Database isn\'t ready or populated yet, showing file config only');
101 97
 		}
102 98
 
103 99
 		if (count($this->args) == 3) {

+ 1
- 5
src/Core/Console/DatabaseStructure.php View File

@@ -56,11 +56,7 @@ HELP;
56 56
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
57 57
 		}
58 58
 
59
-		require_once '.htconfig.php';
60
-		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
61
-		unset($db_host, $db_user, $db_pass, $db_data);
62
-
63
-		if (!$result) {
59
+		if (!\dba::connected()) {
64 60
 			throw new \RuntimeException('Unable to connect to database');
65 61
 		}
66 62
 

+ 2
- 6
src/Core/Console/GlobalCommunityBlock.php View File

@@ -56,12 +56,8 @@ HELP;
56 56
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
57 57
 		}
58 58
 
59
-		require_once '.htconfig.php';
60
-		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
61
-		unset($db_host, $db_user, $db_pass, $db_data);
62
-
63
-		if (!$result) {
64
-			throw new \RuntimeException('Unable to connect to database');
59
+		if ($a->mode == \Friendica\App::MODE_INSTALL) {
60
+			throw new \RuntimeException('Database isn\'t ready or populated yet');
65 61
 		}
66 62
 
67 63
 		$contact_id = Contact::getIdForURL($this->getArgument(0));

+ 2
- 6
src/Core/Console/GlobalCommunitySilence.php View File

@@ -64,12 +64,8 @@ HELP;
64 64
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
65 65
 		}
66 66
 
67
-		require_once '.htconfig.php';
68
-		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
69
-		unset($db_host, $db_user, $db_pass, $db_data);
70
-
71
-		if (!$result) {
72
-			throw new \RuntimeException('Unable to connect to database');
67
+		if ($a->mode == \Friendica\App::MODE_INSTALL) {
68
+			throw new \RuntimeException('Database isn\'t ready or populated yet');
73 69
 		}
74 70
 
75 71
 		/**

+ 2
- 6
src/Core/Console/Maintenance.php View File

@@ -64,12 +64,8 @@ HELP;
64 64
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
65 65
 		}
66 66
 
67
-		require_once '.htconfig.php';
68
-		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
69
-		unset($db_host, $db_user, $db_pass, $db_data);
70
-
71
-		if (!$result) {
72
-			throw new \RuntimeException('Unable to connect to database');
67
+		if ($a->mode == \Friendica\App::MODE_INSTALL) {
68
+			throw new \RuntimeException('Database isn\'t ready or populated yet');
73 69
 		}
74 70
 
75 71
 		Core\Config::load();

+ 2
- 6
src/Core/Console/NewPassword.php View File

@@ -58,12 +58,8 @@ HELP;
58 58
 			throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
59 59
 		}
60 60
 
61
-		require_once '.htconfig.php';
62
-		$result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
63
-		unset($db_host, $db_user, $db_pass, $db_data);
64
-
65
-		if (!$result) {
66
-			throw new \RuntimeException('Unable to connect to database');
61
+		if ($a->mode == \Friendica\App::MODE_INSTALL) {
62
+			throw new \RuntimeException('Database isn\'t ready or populated yet');
67 63
 		}
68 64
 
69 65
 		$nick = $this->getArgument(0);

Loading…
Cancel
Save