Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cache provider does not respect option maxIdLength with versioning enabled #27746

Closed
@kshtompel

Description

@kshtompel

Symfony version(s) affected: *

Description
Component symfony/cache generates cache item ID longer then maxIdLength when versioning is enabled

How to reproduce
Set maxIdLength to 255 provide namespace value with length 231. Enable versioning

class MyAdapter extends AbstractAdapter {
  private $maxIdLength = 255;
}

$adapter = new  MyAdapter(str_repeat('-', 231));
$adapter->enableVersioning(true);
....
$adapter->set(....);
$adapter->save();

// And now we have cache item ID length more then 255 symbols ($maxIdLength + $namespaceVersion)

Possible Solution

\Symfony\Component\Cache\Traits\AbstractTrait::getId()

~265   $this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), ':', - (strlen($this->namespaceVersion) + 2));

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