|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-06-20 14:48 UTC] seld@php.net
Description:
------------
GlobIterator fails to access files present in a valid directory when an open_basedir restriction is in effect. Even if the dir is inside the open_basedir restriction it fails.
Test script:
---------------
ini_set('open_basedir', __DIR__);
var_dump(glob(__DIR__.'/*.php'));
var_dump(iterator_to_array(new GlobIterator(__DIR__.'/*.php')));
Expected result:
----------------
Two lists of php files in the current dir.
Actual result:
--------------
The glob() call returns a list of files, then the GlobIterator explodes with:
UnexpectedValueException: GlobIterator::__construct(): open_basedir restriction in effect. File(glob://C:\Users\seld/*.php) is not within the allowed path(s): (C:\Users\seld) in C:\Users\seld\test.php on line 6
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
I think I can reproduce this. It only happens when the GlobIterator is used inside the destructor, and the script is run using Apache/Mod PHP (running via CLI returns the correct results). <?php error_reporting(-1); ini_set('display_errors', 1); ini_set('open_basedir', __DIR__); class Globber { public function __destruct() { var_dump(__DIR__); var_dump(glob(__DIR__ . '/*.php')); var_dump(iterator_to_array(new \GlobIterator(__DIR__ .'/*.php'))); } } $globber = new Globber; ?> When running via Apache/Mod PHP an UnexpectedValueException is thrown.Ah, just to mention, GlobIterator is the same as DirectoryIterator('glob://....') ... so that on is broken too.