Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getData returns array of strings instead of array of arrays when DisableIS === True #16127

Closed
simonvik opened this issue May 18, 2020 · 4 comments
Assignees
Labels
Bug A problem or regression with an existing feature question Used when we need feedback from the submitter or when the issue is a question about PMA
Projects
Milestone

Comments

@simonvik
Copy link

simonvik commented May 18, 2020

Describe the bug

public function getData($type, $pos, $searchClause = '') in libraries/classes/Navigation/Nodes/NodeTable.php

returns an array of strings instead of an array of arrays if DisableIS is true, that makes

getDisplayName in libraries/classes/Navigation/Nodes/NodeColumn.php fail as it expects an array.

Server configuration

  • phpMyAdmin version: trunk

Additional context

We've made a temporary patch that looks like:

diff -ur phpMyAdmin-5.0.2-all-languages_orig/libraries/classes/Navigation/Nodes/NodeTable.php phpMyAdmin-5.0.2-all-languages/libraries/classes/Navigation/Nodes/NodeTable.php
--- phpMyAdmin-5.0.2-all-languages_orig/libraries/classes/Navigation/Nodes/NodeTable.php	2020-03-21 04:17:40.000000000 +0000
+++ phpMyAdmin-5.0.2-all-languages/libraries/classes/Navigation/Nodes/NodeTable.php	2020-05-18 09:35:32.167217990 +0000
@@ -194,7 +194,13 @@
                 if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
                     while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
                         if ($count < $maxItems) {
-                            $retval[] = $arr['Field'];
+                            $retval[] = array(
+                                'name' => $arr['Field'],
+                                'key' => $arr['Key'],
+                                'type' => $arr['Type'],
+                                'default' =>  $arr['Default'],
+                                'nullable' => ($arr['Null'] == 'NO' ? '' : 'nullable')
+                            );
                             $count++;
                         } else {
                             break;
@williamdes
Copy link
Member

phpMyAdmin version: trunk: phpMyAdmin version: 5.0.2

Thank you for the report !

@williamdes williamdes added this to the 5.0.3 milestone May 18, 2020
@williamdes
Copy link
Member

@simonvik Could you send screenshots of the impact of this change ?

@williamdes williamdes added Bug A problem or regression with an existing feature question Used when we need feedback from the submitter or when the issue is a question about PMA labels May 18, 2020
@simonvik
Copy link
Author

simonvik commented May 18, 2020

Before patch
fail
After patch
fix

Note that SHOW COLUMNS FROM is slightly more verbose than SELECT DATA_TYPE FROM INFORMATION_SCHEMA WHERE ...

It shows the length of int, varchar

@williamdes williamdes added this to Needs triage in issues via automation May 18, 2020
@williamdes williamdes moved this from Needs triage to High priority in issues May 18, 2020
@williamdes williamdes self-assigned this May 19, 2020
williamdes added a commit that referenced this issue May 19, 2020
Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes
Copy link
Member

Seems like it was forgot in #14910

Here is the patch I committed in 481023e

diff --git a/libraries/classes/Navigation/Nodes/NodeTable.php b/libraries/classes/Navigation/Nodes/NodeTable.php
index 89965ebc0d..0790c57cb5 100644
--- a/libraries/classes/Navigation/Nodes/NodeTable.php
+++ b/libraries/classes/Navigation/Nodes/NodeTable.php
@@ -194,7 +194,13 @@ class NodeTable extends NodeDatabaseChild
                 if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
                     while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
                         if ($count < $maxItems) {
-                            $retval[] = $arr['Field'];
+                            $retval[] = [
+                                'name' => $arr['Field'],
+                                'key' => $arr['Key'],
+                                'type' => Util::extractColumnSpec($arr['Type'])['type'],
+                                'default' =>  $arr['Default'],
+                                'nullable' => ($arr['Null'] === 'NO' ? '' : 'nullable'),
+                            ];
                             $count++;
                         } else {
                             break;

this issue will be fixed in the next version, thank you a lot for the patch It took me less time to fix the issue.

issues automation moved this from High priority to Closed May 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature question Used when we need feedback from the submitter or when the issue is a question about PMA
Projects
issues
  
Closed
Development

No branches or pull requests

2 participants