]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
[PEAR][DB] Import some new commits
authorDiogo Cordeiro <diogo@fc.up.pt>
Tue, 6 Aug 2019 01:52:47 +0000 (02:52 +0100)
committerDiogo Cordeiro <diogo@fc.up.pt>
Thu, 8 Aug 2019 01:44:14 +0000 (02:44 +0100)
Patch submitted by XRevan86

[DB/pgsql.php] Change pg_exec to pg_query
Encouraged by http://php.net/manual/en/function.pg-query.php and enables
improved monitoring by New Relic (https://newrelic.com)
[DB.php] changed count to empty for php7.2
[DB/common.php] change to array cast for php72

From: https://github.com/pear/DB/
Commits: 7d0ddaffd04a42a5 and ea9fff4a, respectively

extlib/DB.php
extlib/DB/common.php
extlib/DB/pgsql.php

index e43f6091aba107862d52cb1e7b211740e1470434..18e9a287eaffd0d7efb477d6cfa831fee07d4d9b 100644 (file)
@@ -660,7 +660,7 @@ class DB
             $parsed['dbsyntax'] = $str;
         }
 
-        if (!strlen($dsn)) {
+        if (empty($dsn)) {
             return $parsed;
         }
 
@@ -1503,4 +1503,4 @@ class DB_row
  * tab-width: 4
  * c-basic-offset: 4
  * End:
- */
\ No newline at end of file
+ */
index 7252ce27864bb7b448f16ef8b9d634c295cc47e2..e8750972d76e3e54d6bd16ca373bcb81aac4baa0 100644 (file)
@@ -1319,7 +1319,8 @@ class DB_common extends PEAR
      */
     public function &query($query, $params = array())
     {
-        if (sizeof($params) > 0) {
+        $params = (array)$params;
+        if (count($params)) {
             $sth = $this->prepare($query);
             if (DB::isError($sth)) {
                 return $sth;
@@ -1361,7 +1362,8 @@ class DB_common extends PEAR
     {
         $params = (array)$params;
         // modifyLimitQuery() would be nice here, but it causes BC issues
-        if (sizeof($params) > 0) {
+        $params = (array)$params;
+        if (count($params)) {
             $sth = $this->prepare($query);
             if (DB::isError($sth)) {
                 return $sth;
@@ -1680,7 +1682,8 @@ class DB_common extends PEAR
             }
         }
 
-        if (sizeof($params) > 0) {
+        $params = (array)$params;
+        if (count($params)) {
             $sth = $this->prepare($query);
 
             if (DB::isError($sth)) {
index 251f9d7a89378307778e5b2921b9e691ff201931..e0387a3e22cc7210e3a6646bd158d7cb175b6fda 100644 (file)
@@ -332,14 +332,14 @@ class DB_pgsql extends DB_common
         $query = $this->modifyQuery($query);
         if (!$this->autocommit && $ismanip) {
             if ($this->transaction_opcount == 0) {
-                $result = @pg_exec($this->connection, 'begin;');
+                $result = @pg_query($this->connection, 'begin;');
                 if (!$result) {
                     return $this->pgsqlRaiseError();
                 }
             }
             $this->transaction_opcount++;
         }
-        $result = @pg_exec($this->connection, $query);
+        $result = @pg_query($this->connection, $query);
         if (!$result) {
             return $this->pgsqlRaiseError();
         }
@@ -737,7 +737,7 @@ class DB_pgsql extends DB_common
         if ($this->transaction_opcount > 0) {
             // (disabled) hack to shut up error messages from libpq.a
             //@fclose(@fopen("php://stderr", "w"));
-            $result = @pg_exec($this->connection, 'end;');
+            $result = @pg_query($this->connection, 'end;');
             $this->transaction_opcount = 0;
             if (!$result) {
                 return $this->pgsqlRaiseError();
@@ -757,7 +757,7 @@ class DB_pgsql extends DB_common
     public function rollback()
     {
         if ($this->transaction_opcount > 0) {
-            $result = @pg_exec($this->connection, 'abort;');
+            $result = @pg_query($this->connection, 'abort;');
             $this->transaction_opcount = 0;
             if (!$result) {
                 return $this->pgsqlRaiseError();
@@ -917,7 +917,7 @@ class DB_pgsql extends DB_common
              * Probably received a table name.
              * Create a result resource identifier.
              */
-            $id = @pg_exec($this->connection, "SELECT * FROM $result LIMIT 0");
+            $id = @pg_query($this->connection, "SELECT * FROM $result LIMIT 0");
             $got_string = true;
         } elseif (isset($result->result)) {
             /*
@@ -1011,7 +1011,7 @@ class DB_pgsql extends DB_common
             $tableWhere = "tab.relname = '$table_name'";
         }
 
-        $result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef
+        $result = @pg_query($this->connection, "SELECT f.attnotnull, f.atthasdef
                                 FROM $from
                                 WHERE tab.relname = typ.typname
                                 AND typ.typrelid = f.attrelid
@@ -1022,7 +1022,7 @@ class DB_pgsql extends DB_common
             $flags = ($row[0] == 't') ? 'not_null ' : '';
 
             if ($row[1] == 't') {
-                $result = @pg_exec($this->connection, "SELECT a.adsrc
+                $result = @pg_query($this->connection, "SELECT a.adsrc
                                     FROM $from, pg_attrdef a
                                     WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid
                                     AND f.attrelid = a.adrelid AND f.attname = '$field_name'
@@ -1034,7 +1034,7 @@ class DB_pgsql extends DB_common
         } else {
             $flags = '';
         }
-        $result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey
+        $result = @pg_query($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey
                                 FROM $from, pg_index i
                                 WHERE tab.relname = typ.typname
                                 AND typ.typrelid = f.attrelid