1
1
Fork 0

Fixed E_NOTICE in boot.php and DBA class (#5430)

* Fixes:
- fixed missing variable $port (MySQL: 3306)
- "imported" mysqli class

Signed-off-by: Roland Häder <roland@mxchange.org>

* Fixed:
- better use `false` and `$port > 0`

* And better only provide `$port` when larger zero.

* Initialize `$port` with zero value (int) and not `false` (bool).

* Removed duplicate mysqli "import".

* `$post_update` is no longer used. Instead `$prefix` needs to be checked.
This commit is contained in:
Roland Häder 2018-07-22 18:53:46 +02:00 committed by Hypolite Petovan
parent 3500e50be9
commit 7d47152564
2 changed files with 17 additions and 6 deletions

View file

@ -768,16 +768,20 @@ function run_update_function($x, $prefix)
return false;
} else {
Config::set('database', $funcname, 'success');
if ($post_update) {
if ($prefix == 'update') {
Config::set('system', 'build', $x);
}
return true;
}
} else {
Config::set('database', $funcname, 'success');
if ($post_update) {
if ($prefix == 'update') {
Config::set('system', 'build', $x);
}
return true;
}
}

View file

@ -8,10 +8,10 @@ namespace Friendica\Database;
use Friendica\Core\System;
use Friendica\Util\DateTimeFormat;
use mysqli;
use PDO;
use PDOException;
use PDOStatement;
use mysqli;
/**
* @class MySQL database class
@ -50,6 +50,7 @@ class DBA
self::$db_name = $db;
self::$db_charset = $charset;
$port = 0;
$serveraddr = trim($serveraddr);
$serverdata = explode(':', $serveraddr);
@ -73,7 +74,7 @@ class DBA
self::$driver = 'pdo';
$connect = "mysql:host=".$server.";dbname=".$db;
if (isset($port)) {
if ($port > 0) {
$connect .= ";port=".$port;
}
@ -89,9 +90,15 @@ class DBA
}
}
if (!self::$connected && class_exists('mysqli')) {
if (!self::$connected && class_exists('\mysqli')) {
self::$driver = 'mysqli';
if ($port > 0) {
self::$db = @new mysqli($server, $user, $pass, $db, $port);
} else {
self::$db = @new mysqli($server, $user, $pass, $db);
}
if (!mysqli_connect_errno()) {
self::$connected = true;