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

[phpMyAdmin 5.0.1] Uncaught TypeError when sorting tables by size or by rows #15958

Closed
8ele8 opened this issue Feb 14, 2020 · 3 comments
Closed
Assignees
Labels
Bug A problem or regression with an existing feature
Projects
Milestone

Comments

@8ele8
Copy link

8ele8 commented Feb 14, 2020

Describe the bug

Trying to sort a database's tables by size returns a PHP error of type:

Fatal error: Uncaught TypeError: strtolower() expects parameter 1 to be string, int given in /libraries/classes/DatabaseInterface.php:712 

To Reproduce

Steps to reproduce the behavior:

  1. Open phpMyAdmin and select a database
  2. Under "Structure", click on the "Size" to try to sort the tables by size

Expected behavior

The tables should be sorted by size

Actual behavior

Error message is displayed

Fatal error: Uncaught TypeError: strtolower() expects parameter 1 to be string, int given in /customers/a/5/6/sammensurium.dk/httpd.www/phpMyAdmin-5.0.1_orig/libraries/classes/DatabaseInterface.php:712 

Stack trace: 
#0 /customers/a/5/6/sammensurium.dk/httpd.www/phpMyAdmin-5.0.1_orig/libraries/classes/DatabaseInterface.php(712): strtolower(16384) 
#1 /customers/a/5/6/sammensurium.dk/httpd.www/phpMyAdmin-5.0.1_orig/libraries/classes/Util.php(4623): PhpMyAdmin\DatabaseInterface->getTablesFull('sammensurium_dk...', false, false, 0, 250, 'Data_length', 'DESC', NULL) 
#2 /customers/a/5/6/sammensurium.dk/httpd.www/phpMyAdmin-5.0.1_orig/libraries/classes/Controllers/Database/StructureController.php(106): PhpMyAdmin\Util::getDbInfo('sammensurium_dk...', '_structure') 
#3 /customers/a/5/6/sammensurium.dk/httpd.www/phpMyAdmin-5.0.1_orig/libraries/classes/Controllers/Database/StructureController.php(134): PhpMyAdmin\Controllers\Database\StructureController->getDatabaseInfo('_structure') 
#4 /customers/a/5/6/sammensurium.dk/httpd.www/phpMy in /customers/a/5/6/sammensurium.dk/httpd.www/phpMyAdmin-5.0.1_orig/libraries/classes/DatabaseInterface.php on line 712 

Server configuration

  • Operating system: Ubuntu 18.04.3 LTS
  • Web server: Apache/2.4.41 (Ubuntu)
  • Database version: 10.3.21+maria~bionic
  • PHP version: 7.4.2
  • phpMyAdmin version: 5.0.1

Client configuration

  • Browser: Firefox
  • Operating system: Ubuntu 18.04.4 LTS

Additional info

Tried to debug a bit.
It happens on https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/classes/DatabaseInterface.php#L717-L719

${$sort_by}[$table_name] = strtolower(
                                $table_data['Data_length']
                                + $table_data['Index_length']
                              );

Problem is that $table_data['Data_length'] and $table_data['Index_length'] are of type string,
but $table_data['Data_length'] + $table_data['Index_length'] is an integer

Usually, strtolower should be able to handle this anyway.
But not here due to the declare(strict_types=1); starting the files

Suggestion how to fix

Casting explicitly the resulting sum as a string with a strval() ?

${$sort_by}[$table_name] = strtolower(strval(
                                $table_data['Data_length']
                                + $table_data['Index_length'])
                              );
@williamdes
Copy link
Member

Thank your for the report @8ele8
I will have a look ASAP

@williamdes williamdes added this to Needs triage in issues via automation Feb 14, 2020
@williamdes williamdes moved this from Needs triage to High priority in issues Feb 14, 2020
@williamdes williamdes added this to the 5.0.2 milestone Feb 14, 2020
@williamdes williamdes added the Bug A problem or regression with an existing feature label Feb 14, 2020
@williamdes williamdes changed the title [phpMyAdmin 5.0.1] Uncaught TypeError when sorting tables by size [phpMyAdmin 5.0.1] Uncaught TypeError when sorting tables by size or by rows Feb 14, 2020
@williamdes williamdes self-assigned this Feb 14, 2020
@williamdes
Copy link
Member

NOTICE: PHP message: PHP Fatal error:  Uncaught TypeError: strtolower() expects parameter 1 to be string, null given in libraries/classes/DatabaseInterface.php:718"
Stack trace:"
#0 libraries/classes/DatabaseInterface.php(718): strtolower(NULL)"
#1 libraries/classes/Util.php(4618): PhpMyAdmin\DatabaseInterface->getTablesFull('wdesmenu', false, false, 0, 250, 'Rows', 'DESC', NULL)"
#2 libraries/classes/Controllers/Database/StructureController.php(106): PhpMyAdmin\Util::getDbInfo('wdesmenu', '_structure')"
#3 libraries/classes/Controllers/Database/StructureController.php(134): PhpMyAdmin\Controllers\Database\StructureController->getDatabaseInfo('_structure')"
#4 db_structure.php(56): PhpMyAdmin\Controllers\Database\StructureController->index(Array)"
#5 {main}"

Will also be fixed (sort by "Rows")

williamdes added a commit that referenced this issue Feb 14, 2020
Signed-off-by: William Desportes <williamdes@wdes.fr>
issues automation moved this from High priority to Closed Feb 14, 2020
@8ele8
Copy link
Author

8ele8 commented Feb 16, 2020

Thanks for the quick fix!
Will patch it this way for now at our end - and waiting for the next release :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 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
Projects
issues
  
Closed
Development

No branches or pull requests

2 participants