]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL PDO: Fix bytea without primary key (fix #1021)
authorJakub Vrana <jakub@vrana.cz>
Fri, 11 Apr 2025 13:29:25 +0000 (15:29 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 11 Apr 2025 13:29:59 +0000 (15:29 +0200)
CHANGELOG.md
adminer/include/driver.inc.php
adminer/include/pdo.inc.php

index 6d645e7fed348753c26038e2b8010bc5809a2852..4ce36b09515613d9b8cf702e2e95560e4bfe80b4 100644 (file)
@@ -1,6 +1,7 @@
 ## Adminer dev
 - Fix search anywhere (bug #1004, regression from 5.1.1)
 - Fix import without primary key (bug #1017, regression from 5.1.1)
+- PostgreSQL PDO: Fix bytea without primary key (bug #1021)
 
 ## Adminer 5.2.0 (released 2025-04-08)
 - Autocomplete SQL commands
index dd87c80d2c458bcb580b95f2041b5082b75dcc6b..dc92f53bfd7380175c09e5a035ef3ce2f69b7ba2 100644 (file)
@@ -197,10 +197,7 @@ abstract class SqlDriver {
        * @param Field $field
        */
        function value(?string $val, array $field): ?string {
-               return (method_exists($this->conn, 'value')
-                       ? $this->conn->value($val, $field)
-                       : (is_resource($val) ? stream_get_contents($val) : $val)
-               );
+               return (method_exists($this->conn, 'value') ? $this->conn->value($val, $field) : $val);
        }
 
        /** Quote binary string */
index 149a04c2a87dde602989d293092d73e605caacfd..8332e5b7a1a8575d757ea9d17a9c26b6a6b8c997 100644 (file)
@@ -71,11 +71,20 @@ if (extension_loaded('pdo')) {
                public $_offset = 0, $num_rows;
 
                function fetch_assoc() {
-                       return $this->fetch(\PDO::FETCH_ASSOC);
+                       return $this->fetch_array(\PDO::FETCH_ASSOC);
                }
 
                function fetch_row() {
-                       return $this->fetch(\PDO::FETCH_NUM);
+                       return $this->fetch_array(\PDO::FETCH_NUM);
+               }
+
+               private function fetch_array(int $mode) {
+                       $return = $this->fetch($mode);
+                       return ($return ? array_map(array($this, 'unresource'), $return) : $return);
+               }
+
+               private function unresource($val) {
+                       return (is_resource($val) ? stream_get_contents($val) : $val);
                }
 
                function fetch_field(): \stdClass {