Skip to content

Cache item throw an error on reading with DateTimeImmutable date objects #860

Closed
@jacekkarczmarczyk

Description

@jacekkarczmarczyk

Configuration

  • PhpFastCache version: 9.1
  • PhpFastCache API version: 4.1.0
  • PHP version: 8.1
  • Operating system: win10

Describe the bug

When updating cache item like this:

        $item = $cacheItemPool->getItem('key');
        $item->set('some data');
        $item->setExpirationDate(new DateTimeImmutable('+1 year'));
        $cacheItemPool->save($item);

(which is valid as setExpirationDate allows DateTimeInterface)

phpfastcache fails on reading data:

TypeError: DateTime::createFromFormat(): Argument #2 ($datetime) must be of type string, DateTimeImmutable given

in \Phpfastcache\Core\Pool\DriverBaseTrait::driverUnwrapEdate

Expected behavior
No error when expiration date set to DateTimeImmutable

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions