From b8eb0ad8f588c89eedc600e4fd8e890470dbd18f Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Mon, 24 Mar 2025 09:49:42 +0100 Subject: [PATCH] Notices: Declare properties in fetch_field() --- adminer/drivers/mssql.inc.php | 2 +- adminer/drivers/mysql.inc.php | 3 +-- adminer/drivers/oracle.inc.php | 3 +-- adminer/drivers/pgsql.inc.php | 7 ++----- adminer/drivers/sqlite.inc.php | 2 +- adminer/include/editing.inc.php | 8 +++++--- adminer/include/pdo.inc.php | 3 +-- plugins/drivers/clickhouse.php | 4 ++-- plugins/drivers/firebird.php | 5 ++--- plugins/drivers/imap.php | 2 +- plugins/drivers/mongo.php | 1 + plugins/drivers/simpledb.php | 2 +- 12 files changed, 19 insertions(+), 23 deletions(-) diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index 71035a01..2df08f79 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -140,8 +140,8 @@ if (isset($_GET["mssql"])) { $field = $this->fields[$this->offset++]; $return = new \stdClass; $return->name = $field["Name"]; - $return->orgname = $field["Name"]; $return->type = ($field["Type"] == 1 ? 254 : 0); + $return->charsetnr = 0; return $return; } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index a269a0a6..005d28f6 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -219,12 +219,11 @@ if (!defined('Adminer\DRIVER')) { } /** Fetch next field - * @return object properties: name, type, orgtable, orgname, charsetnr + * @return object properties: name, type (9 for number, 254 for char), charsetnr (63 for binary); optionally: table, orgtable, orgname */ function fetch_field() { $return = mysql_fetch_field($this->result, $this->offset++); // offset required under certain conditions $return->orgtable = $return->table; - $return->orgname = $return->name; $return->charsetnr = ($return->blob ? 63 : 0); return $return; } diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index e8b95f60..587c51b2 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -112,8 +112,7 @@ if (isset($_GET["oracle"])) { $column = $this->offset++; $return = new \stdClass; $return->name = oci_field_name($this->result, $column); - $return->orgname = $return->name; - $return->type = oci_field_type($this->result, $column); + $return->type = oci_field_type($this->result, $column); //! map to MySQL numbers $return->charsetnr = (preg_match("~raw|blob|bfile~", $return->type) ? 63 : 0); // 63 - binary return $return; } diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index cf86b8d7..d4712a2d 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -133,12 +133,9 @@ if (isset($_GET["pgsql"])) { function fetch_field() { $column = $this->offset++; $return = new \stdClass; - if (function_exists('pg_field_table')) { - $return->orgtable = pg_field_table($this->result, $column); - } + $return->orgtable = pg_field_table($this->result, $column); $return->name = pg_field_name($this->result, $column); - $return->orgname = $return->name; - $return->type = pg_field_type($this->result, $column); + $return->type = pg_field_type($this->result, $column); //! map to MySQL numbers $return->charsetnr = ($return->type == "bytea" ? 63 : 0); // 63 - binary return $return; } diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 63bed403..f2f614ac 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -70,7 +70,7 @@ if (isset($_GET["sqlite"])) { function fetch_field() { $column = $this->offset++; - $type = $this->result->columnType($column); + $type = $this->result->columnType($column); //! map to MySQL numbers return (object) array( "name" => $this->result->columnName($column), "type" => $type, diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index f9176517..e89a1f27 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -25,12 +25,14 @@ function select($result, $connection2 = null, $orgtables = array(), $limit = 0) for ($j=0; $j < count($row); $j++) { $field = $result->fetch_field(); $name = $field->name; - $orgtable = $field->orgtable; - $orgname = $field->orgname; - $return[$field->table] = $orgtable; + $orgtable = (isset($field->orgtable) ? $field->orgtable : ""); + $orgname = (isset($field->orgname) ? $field->orgname : $name); if ($orgtables && JUSH == "sql") { // MySQL EXPLAIN $links[$j] = ($name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null)); } elseif ($orgtable != "") { + if (isset($field->table)) { + $return[$field->table] = $orgtable; + } if (!isset($indexes[$orgtable])) { // find primary key in each table $indexes[$orgtable] = array(); diff --git a/adminer/include/pdo.inc.php b/adminer/include/pdo.inc.php index f6fa0a6f..3567727b 100644 --- a/adminer/include/pdo.inc.php +++ b/adminer/include/pdo.inc.php @@ -93,8 +93,7 @@ if (extension_loaded('pdo')) { function fetch_field() { $row = (object) $this->getColumnMeta($this->_offset++); - $row->orgtable = $row->table; - $row->orgname = $row->name; + $row->type = $row->pdo_type; //! map to MySQL numbers $row->charsetnr = (in_array("blob", (array) $row->flags) ? 63 : 0); return $row; } diff --git a/plugins/drivers/clickhouse.php b/plugins/drivers/clickhouse.php index f0a92579..81eadd9e 100644 --- a/plugins/drivers/clickhouse.php +++ b/plugins/drivers/clickhouse.php @@ -125,8 +125,8 @@ if (isset($_GET["clickhouse"])) { $return = new \stdClass; if ($column < count($this->columns)) { $return->name = $this->meta[$column]['name']; - $return->orgname = $return->name; - $return->type = $this->meta[$column]['type']; + $return->type = $this->meta[$column]['type']; //! map to MySQL numbers + $return->charsetnr = 0; } return $return; } diff --git a/plugins/drivers/firebird.php b/plugins/drivers/firebird.php index 3720930b..03c06889 100644 --- a/plugins/drivers/firebird.php +++ b/plugins/drivers/firebird.php @@ -102,9 +102,8 @@ if (isset($_GET["firebird"])) { $field = ibase_field_info($this->result, $this->offset++); return (object) array( 'name' => $field['name'], - 'orgname' => $field['name'], - 'type' => $field['type'], - 'charsetnr' => $field['length'], + 'type' => $field['type'], //! map to MySQL numbers + 'charsetnr' => 0, ); } diff --git a/plugins/drivers/imap.php b/plugins/drivers/imap.php index 16d7bf67..e680598a 100644 --- a/plugins/drivers/imap.php +++ b/plugins/drivers/imap.php @@ -139,7 +139,7 @@ if (isset($_GET["imap"])) { function fetch_field() { $field = current($this->fields); next($this->fields); - return ($field != '' ? (object) array('name' => $field) : false); + return ($field != '' ? (object) array('name' => $field, 'type' => 0, 'charsetnr' => 0) : false); } } } diff --git a/plugins/drivers/mongo.php b/plugins/drivers/mongo.php index 603130ab..62586071 100644 --- a/plugins/drivers/mongo.php +++ b/plugins/drivers/mongo.php @@ -112,6 +112,7 @@ if (isset($_GET["mongo"])) { $name = $keys[$this->offset++]; return (object) array( 'name' => $name, + 'type' => 0, 'charsetnr' => $this->charset[$name], ); } diff --git a/plugins/drivers/simpledb.php b/plugins/drivers/simpledb.php index 8d9c67b2..73918268 100644 --- a/plugins/drivers/simpledb.php +++ b/plugins/drivers/simpledb.php @@ -112,7 +112,7 @@ if (isset($_GET["simpledb"])) { function fetch_field() { $keys = array_keys($this->rows[0]); - return (object) array('name' => $keys[$this->offset++]); + return (object) array('name' => $keys[$this->offset++], 'type' => 0, 'charsetnr' => 0); } } }