Skip to content

[FrameworkBundle] Second invocation of cache:clear command crashes on macOS #39552

Closed
@alongosz

Description

@alongosz

Symfony version(s) affected: 5.2.x-dev (5.2.1@dev)

Description

Since #39360 the code checking if a cache dir is NFS changed a bit with respect to v5.2.0 and unfortunately this change causes cache:clear command to crash on macOS

How to reproduce

composer create-project symfony/skeleton:^5.2.1@dev
cd skeleton
php bin/console cache:clear

// note that the first invocation of cache:clear is done while creating a project

This results in the following error:

In CacheClearCommand.php line 220:
  Warning: Invalid argument supplied for foreach()

This is because /proc/mounts does not exist on macOS which makes $mounts variable false, while the line 220 expects it to be an array.

Possible Solution

The possible solution might be either checking if the variable is an array before iterating in the line 220 or actually using separate variable to read mounts from file since it could be false.

That said, if the intention there was for NFS to work on macOS then the solution would be different (unknown to me at this point), which stopped me from providing the actual patch without Your feedback.

Additional context

I know this refers to an unreleased version, however per Your recommendation (#39360 (comment)) we've upgraded Ibexa DXP dev version to use that, so we can test it on v5.2. Right now it's a blocker for our developers using macOS.

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