]> git.mxchange.org Git - friendica.git/commitdiff
Fixed E_NOTICE in boot.php and DBA class (#5430)
authorRoland Häder <Quix0r@users.noreply.github.com>
Sun, 22 Jul 2018 16:53:46 +0000 (18:53 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Sun, 22 Jul 2018 16:53:46 +0000 (12:53 -0400)
* 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.

boot.php
src/Database/DBA.php

index 4c3a8c5ca88f371647cd3e02d675218c17d5c390..17caa19033c40efcdc5a37fc9a1808262b673312 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -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;
        }
 }
index 51b2c8898e6b49524d6d0000c6d146ad17aa6092..3fae84c76637c216ae7d90fe4fbf43af131d34ae 100644 (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';
-                       self::$db = @new mysqli($server, $user, $pass, $db, $port);
+
+                       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;