]> git.mxchange.org Git - friendica.git/commitdiff
"dba" is now "DBA". This hadn't been respected at some places (#5655)
authorMichael Vogel <icarus@dabo.de>
Thu, 23 Aug 2018 13:51:58 +0000 (15:51 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Thu, 23 Aug 2018 13:51:58 +0000 (09:51 -0400)
* "dba" is now "DBA". This hadn't been respected at some places

* Cleaning up unneeded stuff

include/dba.php
src/Core/System.php
src/Database/DBA.php
src/Model/Group.php
src/Protocol/Diaspora.php

index 6480b28ed2feaeaac517d0f6e0debdf291d4ae70..9e168eac799c36e6a53eefdd8ab68e9e99313405 100644 (file)
@@ -5,9 +5,9 @@ use Friendica\Database\DBA;
 /**
  * @brief execute SQL query with printf style args - deprecated
  *
- * Please use the dba:: functions instead:
- * dba::select, dba::exists, dba::insert
- * dba::delete, dba::update, dba::p, dba::e
+ * Please use the DBA:: functions instead:
+ * DBA::select, DBA::exists, DBA::insert
+ * DBA::delete, DBA::update, DBA::p, DBA::e
  *
  * @param $args Query parameters (1 to N parameters of different types)
  * @return array|bool Query array
index 4e2b63f044bbb2ae30ee374924671bf37c3f040e..88b89cda27ac60189375854ecca2a103439ff4d2 100644 (file)
@@ -65,7 +65,7 @@ class System extends BaseObject
                while ($func = array_pop($trace)) {
                        if (!empty($func['class'])) {
                                // Don't show multiple calls from the "dba" class to show the essential parts of the callstack
-                               if ((($previous['class'] != $func['class']) || ($func['class'] != 'dba')) && ($previous['function'] != 'q')) {
+                               if ((($previous['class'] != $func['class']) || ($func['class'] != 'Friendica\Database\DBA')) && ($previous['function'] != 'q')) {
                                        $classparts = explode("\\", $func['class']);
                                        $callstack[] = array_pop($classparts).'::'.$func['function'];
                                        $previous = $func;
index 9dc1984afb130eb2551170a4415daa0289c6df80..bf480dad2c769ce0dce42c2f22878958c25536f5 100644 (file)
@@ -372,7 +372,7 @@ class DBA
         * @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
         *
         * Please only use it with complicated queries.
-        * For all regular queries please use dba::select or dba::exists
+        * For all regular queries please use DBA::select or DBA::exists
         *
         * @param string $sql SQL statement
         * @return bool|object statement object or result object
@@ -590,7 +590,7 @@ class DBA
        /**
         * @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
         *
-        * Please use dba::delete, dba::insert, dba::update, ... instead
+        * Please use DBA::delete, DBA::insert, DBA::update, ... instead
         *
         * @param string $sql SQL statement
         * @return boolean Was the query successfull? False is returned only if an error occurred
@@ -685,7 +685,7 @@ class DBA
        /**
         * Fetches the first row
         *
-        * Please use dba::selectFirst or dba::exists whenever this is possible.
+        * Please use DBA::selectFirst or DBA::exists whenever this is possible.
         *
         * @brief Fetches the first row
         * @param string $sql SQL statement
@@ -1303,7 +1303,7 @@ class DBA
         *
         * $params = array("order" => array("id", "received" => true), "limit" => 10);
         *
-        * $data = dba::select($table, $fields, $condition, $params);
+        * $data = DBA::select($table, $fields, $condition, $params);
         */
        public static function select($table, array $fields = [], array $condition = [], array $params = [])
        {
@@ -1345,7 +1345,7 @@ class DBA
         * or:
         * $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
         *
-        * $count = dba::count($table, $condition);
+        * $count = DBA::count($table, $condition);
         */
        public static function count($table, array $condition = [])
        {
@@ -1399,7 +1399,7 @@ class DBA
                                                /* Workaround for MySQL Bug #64791.
                                                 * Never mix data types inside any IN() condition.
                                                 * In case of mixed types, cast all as string.
-                                                * Logic needs to be consistent with dba::p() data types.
+                                                * Logic needs to be consistent with DBA::p() data types.
                                                 */
                                                $is_int = false;
                                                $is_alpha = false;
@@ -1530,7 +1530,7 @@ class DBA
                        case 'mysqli':
                                // MySQLi offers both a mysqli_stmt and a mysqli_result class.
                                // We should be careful not to assume the object type of $stmt
-                               // because dba::p() has been able to return both types.
+                               // because DBA::p() has been able to return both types.
                                if ($stmt instanceof mysqli_stmt) {
                                        $stmt->free_result();
                                        $ret = $stmt->close();
index b01fc197014ad2ce9684ce4b05d39cc6bd1afc94..71f794118940f2032bdf59fac3e1cb44c2c7043b 100644 (file)
@@ -273,36 +273,25 @@ class Group extends BaseObject
         *
         * @param array $group_ids
         * @param boolean $check_dead
-        * @param boolean $use_gcontact
         * @return array
         */
-       public static function expand($group_ids, $check_dead = false, $use_gcontact = false)
+       public static function expand($group_ids, $check_dead = false)
        {
                if (!is_array($group_ids) || !count($group_ids)) {
                        return [];
                }
 
-               $condition = '`gid` IN (' . substr(str_repeat("?, ", count($group_ids)), 0, -2) . ')';
-               if ($use_gcontact) {
-                       $sql = 'SELECT `gcontact`.`id` AS `contact-id` FROM `group_member`
-                                       INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
-                                       INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
-                               WHERE ' . $condition;
-                       $param_arr = array_merge([$sql], $group_ids);
-                       $stmt = call_user_func_array('dba::p', $param_arr);
-               } else {
-                       $condition_array = array_merge([$condition], $group_ids);
-                       $stmt = DBA::select('group_member', ['contact-id'], $condition_array);
-               }
+               $stmt = DBA::select('group_member', ['contact-id'], ['gid' => $group_ids]);
 
                $return = [];
                while($group_member = DBA::fetch($stmt)) {
                        $return[] = $group_member['contact-id'];
                }
 
-               if ($check_dead && !$use_gcontact) {
+               if ($check_dead) {
                        Contact::pruneUnavailable($return);
                }
+
                return $return;
        }
 
index e62329e180a0fb1471a4edfbeea8763eb1017a15..a7f34b7a6dc8b43496fd6b1c2b3534a98b829fce 100644 (file)
@@ -1050,7 +1050,7 @@ class Diaspora
                        return false;
                }
 
-               $contact = dba::selectFirst('contact', [], ['id' => $cid]);
+               $contact = DBA::selectFirst('contact', [], ['id' => $cid]);
                if (!DBA::isResult($contact)) {
                        // This here shouldn't happen at all
                        logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG);
@@ -1079,7 +1079,7 @@ class Diaspora
                // It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
                // It is not removed by now. Possibly the code is needed?
                //if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(Contact::PAGE_FREELOVE))) {
-               //      dba::update(
+               //      DBA::update(
                //              'contact',
                //              array('rel' => Contact::FRIEND, 'writable' => true),
                //              array('id' => $contact["id"], 'uid' => $contact["uid"])