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

open_basedir warning on import with PHP8 #16729

Closed
KodaCHC opened this issue Mar 12, 2021 · 11 comments
Closed

open_basedir warning on import with PHP8 #16729

KodaCHC opened this issue Mar 12, 2021 · 11 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Projects
Milestone

Comments

@KodaCHC
Copy link

KodaCHC commented Mar 12, 2021

When I use PHP8 I get this error when importing:

Warning in ./libraries/classes/FileListing.php#33
 file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/user/:/tmp/)

Backtrace

FileListing.php#33: file_exists(string '/')
FileListing.php#77: PhpMyAdmin\FileListing->getDirContent(
string '/',
string '@\\.(csv|shp|ods|sql|txt|xml)(\\.(gz|bz2|zip))?$@',
)
Import.php#1836: PhpMyAdmin\FileListing->getFileSelectOptions(
string '/',
string '@\\.(csv|shp|ods|sql|txt|xml)(\\.(gz|bz2|zip))?$@',
string '',
)
ImportController.php#132: PhpMyAdmin\Import::getLocalFiles(array)
Routing.php#186: PhpMyAdmin\Controllers\Database\ImportController->index(array)
index.php#18: PhpMyAdmin\Routing::callControllerForRoute(
string '/database/import',
,
,
)

phpMyAdmin has version 5.1.0

When I switch to PHP7.4 it works without error

@williamdes
Copy link
Member

Hi @KodaCHC
Thank you for reporting this issue, indeed there is a difference and normally the error should be hidden.
I could confirm this while working on #16709 some hours ago

@williamdes williamdes added the Bug A problem or regression with an existing feature label Mar 12, 2021
@williamdes williamdes added this to Needs triage in issues via automation Mar 12, 2021
@williamdes williamdes added this to the 5.1.1 milestone Mar 12, 2021
@williamdes williamdes moved this from Needs triage to PHP 8 in issues Mar 12, 2021
@williamdes
Copy link
Member

@KodaCHC
Copy link
Author

KodaCHC commented Mar 12, 2021

Thank you :)

@williamdes
Copy link
Member

https://www.php.net/manual/en/migration80.incompatible.php
https://www.php.net/manual/fr/function.error-reporting.php#125674

// The @ operator will no longer silence fatal errors (E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR, E_PARSE). Error handlers that expect error_reporting to be 0 when @ is used, should be adjusted to use a mask check instead:

<?php
// Replace
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
    if (error_reporting() == 0) {
        return false; // Silenced
    }
    // ...
}

// With
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
    if (!(error_reporting() & $err_no)) {
        return false; // Silenced
    }
    // ...
}
?>

from https://www.php.net/manual/en/migration80.incompatible.php

@williamdes
Copy link
Member

Hi @Ayesh
The above links would be helpfull in https://php.watch/versions/8.0/fatal-error-suppression

@williamdes williamdes self-assigned this Mar 12, 2021
@williamdes
Copy link
Member

Hi @KodaCHC
Could you apply c4c32c3 and let me know if that works for you too ?

williamdes added a commit that referenced this issue Mar 12, 2021
Signed-off-by: William Desportes <williamdes@wdes.fr>
@KodaCHC
Copy link
Author

KodaCHC commented Mar 14, 2021

Please excuse the late reply. I had not installed phpMyAdmin from GIT until now. I have now made up for this, but now already get errors on every page.

Warning in ./libraries/classes/ThemeManager.php#228
 is_dir(): open_basedir restriction in effect. File(/var/www/myuser/html/phpmyadmin/themes/dot.gif/) is not within the allowed path(s): (/var/www/myuser/:/tmp/)

Backtrace

ThemeManager.php#228: is_dir(string '/var/www/myuser/html/phpmyadmin/themes/dot.gif/')
ThemeManager.php#66: PhpMyAdmin\ThemeManager->loadThemes()
ThemeManager.php#108: PhpMyAdmin\ThemeManager->__construct()
ThemeManager.php#277: PhpMyAdmin\ThemeManager::getInstance()
common.inc.php#242: PhpMyAdmin\ThemeManager::initializeTheme()
index.php#15: require_once(./libraries/common.inc.php)

Warning in ./libraries/classes/ThemeManager.php#228
 is_dir(): open_basedir restriction in effect. File(/var/www/myuser/html/phpmyadmin/themes/.gitignore/) is not within the allowed path(s): (/var/www/myuser/:/tmp/)

Backtrace

ThemeManager.php#228: is_dir(string '/var/www/myuser/html/phpmyadmin/themes/.gitignore/')
ThemeManager.php#66: PhpMyAdmin\ThemeManager->loadThemes()
ThemeManager.php#108: PhpMyAdmin\ThemeManager->__construct()
ThemeManager.php#277: PhpMyAdmin\ThemeManager::getInstance()
common.inc.php#242: PhpMyAdmin\ThemeManager::initializeTheme()
index.php#15: require_once(./libraries/common.inc.php)

I need to see if I made a mistake here when installing from GIT

Version information: 5.2.0-dev, latest stable version: 5.1.0
Git revision: d7bfe37 from master branch,
committed on Mar 12, 2021 at 04:06 PM by William Desportes,
authored on Mar 12, 2021 at 04:05 PM by William Desportes

issues automation moved this from PHP 8 to Closed Mar 14, 2021
@williamdes
Copy link
Member

Please excuse the late reply. I had not installed phpMyAdmin from GIT until now. I have now made up for this, but now already get errors on every page.

Warning in ./libraries/classes/ThemeManager.php#228
 is_dir(): open_basedir restriction in effect. File(/var/www/myuser/html/phpmyadmin/themes/dot.gif/) is not within the allowed path(s): (/var/www/myuser/:/tmp/)

Backtrace

ThemeManager.php#228: is_dir(string '/var/www/myuser/html/phpmyadmin/themes/dot.gif/')
ThemeManager.php#66: PhpMyAdmin\ThemeManager->loadThemes()
ThemeManager.php#108: PhpMyAdmin\ThemeManager->__construct()
ThemeManager.php#277: PhpMyAdmin\ThemeManager::getInstance()
common.inc.php#242: PhpMyAdmin\ThemeManager::initializeTheme()
index.php#15: require_once(./libraries/common.inc.php)

Warning in ./libraries/classes/ThemeManager.php#228
 is_dir(): open_basedir restriction in effect. File(/var/www/myuser/html/phpmyadmin/themes/.gitignore/) is not within the allowed path(s): (/var/www/myuser/:/tmp/)

Backtrace

ThemeManager.php#228: is_dir(string '/var/www/myuser/html/phpmyadmin/themes/.gitignore/')
ThemeManager.php#66: PhpMyAdmin\ThemeManager->loadThemes()
ThemeManager.php#108: PhpMyAdmin\ThemeManager->__construct()
ThemeManager.php#277: PhpMyAdmin\ThemeManager::getInstance()
common.inc.php#242: PhpMyAdmin\ThemeManager::initializeTheme()
index.php#15: require_once(./libraries/common.inc.php)

I need to see if I made a mistake here when installing from GIT

Version information: 5.2.0-dev, latest stable version: 5.1.0
Git revision: d7bfe37 from master branch,
committed on Mar 12, 2021 at 04:06 PM by William Desportes,
authored on Mar 12, 2021 at 04:05 PM by William Desportes

In fact I made the changes on the QA_5_1 branch but you now can fetch the branch master, I just pushed the merge now

@KodaCHC
Copy link
Author

KodaCHC commented Mar 14, 2021

Great. Thank you. Works

@Ayesh
Copy link

Ayesh commented Mar 16, 2021

Thank you for the information about error_reporting function. I updated the PHP.Watch page with a new section for error reporting return values.

@williamdes
Copy link
Member

Thank you for the information about error_reporting function. I updated the PHP.Watch page with a new section for error reporting return values.

Thank you very much !

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 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

3 participants