Skip to content

[Cache] PhpArrayAdapter logs error on initialize of non-existent file #20901

Closed
@ruudk

Description

@ruudk
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.1

Just installed 3.2.1 on PHP 7.1 in production and got the following error logged to Sentry:

Symfony\Component\Debug\Exception\FatalErrorException: include(): Failed opening '/home/ticketswap/app/releases/20161213142627/app/cache/prod/annotations.php' for inclusion (include_path='.:/usr/share/php')
#1 /vendor/symfony/symfony/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php(331): null
#0 Hautelook\SentryClient\ErrorHandler(null): Hautelook\SentryClient\ErrorHandler::handleFatalError

I had a similar issue in the PR I submitted yesterday #20883. That issue is now gone, but the next issue arises.

The issue is with this code:

$this->values = @(include $this->file) ?: array();

    /**
     * Load the cache file.
     */
    private function initialize()
    {
        $this->values = @(include $this->file) ?: array();
    }

The error suppression still triggers an error (in PHP 7.1 with error_reporting = E_ALL).

Isn't it better to first check if the file exists?

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