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.1.1 with PHP 7.4.6 : Fatal error: Uncaught TypeError: mb_substr() expects parameter 1 to be string #17026

Closed
Whisper40 opened this issue Jul 22, 2021 · 6 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Projects
Milestone

Comments

@Whisper40
Copy link

Whisper40 commented Jul 22, 2021

Describe the bug

We have deployed these packages :
Mysql : 8.0.21
PHP : 7.4.6
PhpMyAdmin : 5.1.1

We can without problem navigate into structure, we can create tables, but we cannot go on "import" and "export" tables.

Export tab is throwing this error :

Fatal error: Uncaught TypeError: mb_substr() expects parameter 1 to be string, bool given in /opt/app-root/src/libraries/classes/Util.php:1351 Stack trace: #0 /opt/app-root/src/libraries/classes/Util.php(1351): mb_substr(false, -1) #1 /opt/app-root/src/libraries/classes/Export/Options.php(191): PhpMyAdmin\Util::userDir(false) #2 /opt/app-root/src/libraries/classes/Controllers/Database/ExportController.php(156): PhpMyAdmin\Export\Options->getOptions('database', 'mydb', '', '', 1, 0, Array) #3 /opt/app-root/src/libraries/classes/Routing.php(187): PhpMyAdmin\Controllers\Database\ExportController->index(Array) #4 /opt/app-root/src/index.php(18): PhpMyAdmin\Routing::callControllerForRoute('/database/expor...', Object(FastRoute\Dispatcher\GroupCountBased), Object(Symfony\Component\DependencyInjection\ContainerBuilder)) #5 {main} thrown in /opt/app-root/src/libraries/classes/Util.php on line 1351

And import tab is throwing this :

Fatal error: Uncaught TypeError: mb_substr() expects parameter 1 to be string, bool given in /opt/app-root/src/libraries/classes/Util.php:1351 Stack trace: #0 /opt/app-root/src/libraries/classes/Util.php(1351): mb_substr(false, -1) #1 /opt/app-root/src/libraries/classes/Controllers/Database/ImportController.php(131): PhpMyAdmin\Util::userDir(false) #2 /opt/app-root/src/libraries/classes/Routing.php(187): PhpMyAdmin\Controllers\Database\ImportController->index(Array) #3 /opt/app-root/src/index.php(18): PhpMyAdmin\Routing::callControllerForRoute('/database/impor...', Object(FastRoute\Dispatcher\GroupCountBased), Object(Symfony\Component\DependencyInjection\ContainerBuilder)) #4 {main} thrown in /opt/app-root/src/libraries/classes/Util.php on line 1351

To Reproduce

1.Install these packages :
Mysql : 8.0.21
PHP : 7.4.6
PhpMyAdmin : 5.1.1
2.Click on 'import' or "export"
3. See error

Expected behavior

We should be able to access to these tabs

Screenshots

image

Server configuration

  • Operating system: Docker Container -> registry.redhat.io/ubi8/php-74
  • Web server: Apache
  • Database version: 8.0.21
  • PHP version: 7.4.6
  • phpMyAdmin version: 5.1.1

Client configuration

  • Browser: Chrome
  • Operating system: Win 10

We already tried to clear our cache/cookies. Same in private browser.

@williamdes
Copy link
Member

Hi @Whisper40
I think you have no value of the wrong value for $cfg['SaveDir'] or $cfg['UploadDir']

Meanwhile, I will fix the code to handle this case

@williamdes williamdes added the Bug A problem or regression with an existing feature label Jul 22, 2021
@williamdes williamdes added this to the 5.1.2 milestone Jul 22, 2021
@williamdes williamdes added this to Needs triage in issues via automation Jul 22, 2021
@williamdes williamdes moved this from Needs triage to to be fixed soon in issues Jul 22, 2021
@Whisper40
Copy link
Author

Whisper40 commented Jul 22, 2021

Hi @williamdes I have these values :

$cfg['UploadDir'] = getenv('DATA_PATH');
$cfg['SaveDir'] = getenv('DATA_PATH');

The configuration on our side of "config.inc.php" does not change between (php-71-rhel7 with phpmyadmin 5.0.4) and (ubi8/php-74 with phpmyadmin 5.1.1)

@williamdes
Copy link
Member

williamdes commented Jul 22, 2021

Ah ! 🇫🇷
But this function also returns false ;)
https://www.php.net/manual/en/function.getenv.php

$cfg['UploadDir'] = (string) getenv('DATA_PATH');
$cfg['SaveDir'] = (string) getenv('DATA_PATH');

Or maybe

$cfg['UploadDir'] = getenv('DATA_PATH') ?? 'defaultValueReplaceMe';
$cfg['SaveDir'] = getenv('DATA_PATH') ?? 'defaultValueReplaceMe';

Probably one of the ENVs is not defined

@Whisper40
Copy link
Author

You are right :)
Env is not defined in the container...
Will try to find why..

Sry to have broken the code by doing this ahah

@williamdes williamdes self-assigned this Jul 22, 2021
@Whisper40
Copy link
Author

Whisper40 commented Jul 22, 2021

Just for information :

getenv('DATA_PATH') ?? '';  // ?? does not work 
'' // default value works

( you can close when you want )

@williamdes
Copy link
Member

Thanks for the feedback, I was indeed afraid it would not handle false the same way as null

I will push my commits and the issue will close itself

williamdes added a commit that referenced this issue Jul 22, 2021
Signed-off-by: William Desportes <williamdes@wdes.fr>
issues automation moved this from to be fixed soon to Closed Jul 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2022
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