Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CacheClearCommand: open_basedir restriction warning #54402

Closed
@kopfsalat

Description

@kopfsalat

Symfony version(s) affected

6.4.5

Description

Hi,
we're runnning our Symfony project in a php environment with open_basedir restrictions. Since upgrading to 6.4.5 the behavior of the cache:clear command changed. We now get a "Warning: is_readable(): open_basedir restriction in effect. File(/proc/mounts) is not within the allowed path(s): ..." warning. It gets triggered by the isNfs(string $dir) method in Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.

I was able to narrow it down to this commit:
[FrameworkBundle] Prevent silenced warning by checking if /proc/mount… (349b3e7)

How to reproduce

To reproduce run symfony in an php environment with config
open_basedir = /var/www/
or likely and run the cache:clear command.

Possible Solution

Since is_readable() produces meaningful output even when restricted by open_basedir config, changing the if statement from

if ('/' === \DIRECTORY_SEPARATOR && is_readable('/proc/mounts') && $files = @file('/proc/mounts'))
to
if ('/' === \DIRECTORY_SEPARATOR && @is_readable('/proc/mounts') && $files = @file('/proc/mounts'))

would suppress the error without having any negative side effects.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions