Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FrameworkBundle] About Command throws RuntimeException #39916

Copy link
Copy link
Closed
@michaljusiega

Description

@michaljusiega
Issue body actions

Symfony version(s) affected: 4.4, 5.1, 5.2

Description
During running command about in production envinroment, I get an exception:

In AboutCommand.php line 128:

  SplFileInfo::getSize(): stat failed for /var/www/intranet/var/cache/prod_linux/jms_serializer/annotations/1a/5b4c75
  786d65645c496e7472616e65745c44544f5c536572766963655c48545450436c69656e745c4d53506f637a74615c506f637a74615a65776e657
  4727a6e61416c6961737953657269616c697a65725d5b315d.doctrinecache.data

because file is not currently readable.

How to reproduce
php bin/console about --env=prod --no-debug

Possible Solution
Implement CallbackFilterIterator to RecursiveIteratorIterator and check if file is_readable().

From:

            $size = 0;
            foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS | \RecursiveDirectoryIterator::FOLLOW_SYMLINKS)) as $file) {
                $size += $file->getSize();
            }

to

            $size = 0;
            $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS | \RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
            // https://www.php.net/manual/en/class.callbackfilteriterator.php
            $iterator = new \CallbackFilterIterator($iterator, function (\SplFileInfo $current): bool {
                return is_readable($current->getPathname());
            });

            foreach ($iterator as $file) {
                $size += $file->getSize();
            }

Additional context
https://github.com/symfony/symfony/blob/5.x/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php#L117

I'm ready to fix this with my suggestion :)

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.