is_dir(): open_basedir restriction in effect
-
Hi,
since moving to a new hoster that actually enforces some version of the
open_basedir
restriction, we’ve been hitting that warning whenever a replace is executed:PHP Warning: is_dir(): open_basedir restriction in effect. File(/wp-content/uploads/{basename}) is not within the allowed path(s): ({list of dirs, incl. wp base dir}) in /srv/wp-content/plugins/enable-media-replace/classes/ <a href="https://github.com/short-pixel-optimizer/enable-media-replace/blob/master/classes/replacer.php#L472">replacer.php on line 472</a>
Looking at the code, the issue seems to be from
parse_url(…, PHP_URL_PATH)
@ 465:PHP_URL_PATH
will have parse_url always return a string starting with/
– unless the URL contains no path at all, then it’ll return NULL – and this will be taken as prohibited absolute path (so starting from root, rather than wp’s base dir) to an open_basedir’ed is_dir().I guess the fix would be to prepend wp’s base dir, or just check for initial / and remove it from that string, like so.
- The topic ‘is_dir(): open_basedir restriction in effect’ is closed to new replies.