mirror of
https://github.com/friendica/friendica
synced 2025-04-24 23:10:11 +00:00
Add meaningful return value to dba::connect
- Move System::unavailable call to index
This commit is contained in:
parent
dcf2ed26bb
commit
881c7ccfc1
2 changed files with 7 additions and 11 deletions
|
@ -13,7 +13,7 @@ use Friendica\Util\DateTimeFormat;
|
|||
*/
|
||||
|
||||
class dba {
|
||||
public static $connected = true;
|
||||
public static $connected = false;
|
||||
|
||||
private static $_server_info = '';
|
||||
private static $db;
|
||||
|
@ -48,8 +48,6 @@ class dba {
|
|||
$db = trim($db);
|
||||
|
||||
if (!(strlen($server) && strlen($user))) {
|
||||
self::$connected = false;
|
||||
self::$db = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -57,8 +55,6 @@ class dba {
|
|||
if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
|
||||
if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
|
||||
self::$error = L10n::t('Cannot locate DNS info for database server \'%s\'', $server);
|
||||
self::$connected = false;
|
||||
self::$db = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +75,6 @@ class dba {
|
|||
self::$db = @new PDO($connect, $user, $pass);
|
||||
self::$connected = true;
|
||||
} catch (PDOException $e) {
|
||||
self::$connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,13 +93,10 @@ class dba {
|
|||
// No suitable SQL driver was found.
|
||||
if (!self::$connected) {
|
||||
self::$db = null;
|
||||
if (!$install) {
|
||||
System::unavailable();
|
||||
}
|
||||
}
|
||||
$a->save_timestamp($stamp1, "network");
|
||||
|
||||
return true;
|
||||
return self::$connected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue