8000 [Cache] unable to fetch cached enums with PhpFilesAdapter · Issue #48967 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content < 8000 script crossorigin="anonymous" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_document-metadata_document-metadata_ts-ui_packages_hydro-analytics_hydro-analytic-f29230-07417997172c.js" defer="defer">
[Cache] unable to fetch cached enums with PhpFilesAdapter #48967
Closed
@jasiolpn

Description

@jasiolpn

Symfony version(s) affected

6.2

Description

When using PhpFilesAdater it's impossible to restore cached enums because of invalid namespace resolving. I have found that before file export this adapter is replacing VarExporter component fully qualified class names to namespace declaration:

$value = str_replace('\Symfony\Component\VarExporter\Internal\\', '', $value);
$value = "namespace Symfony\Component\VarExporter\Internal;\n\nreturn \$getExpiry ? {$expiry} : {$value};";

This generates following error on cache restore:

Fatal error: Uncaught Error: Class "Symfony\Component\VarExporter\Internal\Bug\Deep\Enum\Ns\FooEnum" not found in /xxx/M++2dAPuxQXg9Krv80eQ:16

How to reproduce

I have prepared repository with example code which can be used to reproduce this issue:

  1. clone https://github.com/jasiolpn/symfony-php-files-cache-adapter-enum-bug
  2. install dependencies via composer
  3. run reproduce.php file twice. First run will generate file with cached content, second one will try to resore this content but it will fail with mentioned error

Possible Solution

No response

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

      0