Doctrine\Common\Cache\CacheProvider::getNamespaceVersion() could fail in case of corrupted cache entry #5655

Closed
opened 2026-01-22 15:13:50 +01:00 by admin · 3 comments
Owner

Originally created by @jocel1 on GitHub (Aug 24, 2017).

Originally assigned to: @lcobucci on GitHub.

Hi!

I'm hitting an issue with Doctrine\Common\Cache\CacheProvider::getNamespaceVersion() & a redis cache.
It seems at some point the redis cache has been corrupted, and the doFetch() returns a string instead of an int. In this case it throws an exception:

Return value of Doctrine\Common\Cache\CacheProvider::getNamespaceVersion() must be of the type integer, string returned

because the function is expected to return an int.
Why not adding an extra conversion like

$this->namespaceVersion = ((int)$this->doFetch($namespaceCacheKey)) ?: 1;

?

Thanks!

Originally created by @jocel1 on GitHub (Aug 24, 2017). Originally assigned to: @lcobucci on GitHub. Hi! I'm hitting an issue with Doctrine\Common\Cache\CacheProvider::getNamespaceVersion() & a redis cache. It seems at some point the redis cache has been corrupted, and the doFetch() returns a string instead of an int. In this case it throws an exception: ```Return value of Doctrine\Common\Cache\CacheProvider::getNamespaceVersion() must be of the type integer, string returned``` because the function is expected to return an int. Why not adding an extra conversion like ```php $this->namespaceVersion = ((int)$this->doFetch($namespaceCacheKey)) ?: 1; ``` ? Thanks!
admin added the Invalid label 2026-01-22 15:13:50 +01:00
admin closed this issue 2026-01-22 15:13:50 +01:00
Author
Owner

@Ocramius commented on GitHub (Aug 24, 2017):

If you can add a test case, this can be patched in quite quickly

On 24 Aug 2017 2:29 PM, "Jocelyn Fournier" notifications@github.com wrote:

Hi!

I'm hitting an issue with getNamespaceVersion() & a redis cache.
It seems at some point the redis cache has been corrupted, and the
doFetch() returns a string instead of an int. In this case it throws an
exception:

Return value of Doctrine\Common\Cache\CacheProvider::getNamespaceVersion()
must be of the type integer, string returned

because the function is expected to return an int.
Why not adding an extra conversion like

$this->namespaceVersion = ((int)$this->doFetch($namespaceCacheKey)) ?: 1;

?

Thanks!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6645, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakGTiJ1GfcRmGojCrubtNfjnYx6EMks5sbWy9gaJpZM4PBT5R
.

@Ocramius commented on GitHub (Aug 24, 2017): If you can add a test case, this can be patched in quite quickly On 24 Aug 2017 2:29 PM, "Jocelyn Fournier" <notifications@github.com> wrote: > Hi! > > I'm hitting an issue with getNamespaceVersion() & a redis cache. > It seems at some point the redis cache has been corrupted, and the > doFetch() returns a string instead of an int. In this case it throws an > exception: > > Return value of Doctrine\Common\Cache\CacheProvider::getNamespaceVersion() > must be of the type integer, string returned > > because the function is expected to return an int. > Why not adding an extra conversion like > > $this->namespaceVersion = ((int)$this->doFetch($namespaceCacheKey)) ?: 1; > > ? > > Thanks! > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/6645>, or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakGTiJ1GfcRmGojCrubtNfjnYx6EMks5sbWy9gaJpZM4PBT5R> > . >
Author
Owner

@jocel1 commented on GitHub (Aug 24, 2017):

@Ocramius I've just quickly added a test here: https://github.com/doctrine/doctrine2/pull/6646
I would have prefered in the cache repo, but I haven't figured out yet how to run phpunit from their.

@jocel1 commented on GitHub (Aug 24, 2017): @Ocramius I've just quickly added a test here: https://github.com/doctrine/doctrine2/pull/6646 I would have prefered in the cache repo, but I haven't figured out yet how to run phpunit from their.
Author
Owner

@lcobucci commented on GitHub (Aug 24, 2017):

@jocel1 I've moved your test to doctrine/cache#231 and applied the fix, so I'll close this issue as invalid since it's not related to the ORM. Thanks for your contribution!

@lcobucci commented on GitHub (Aug 24, 2017): @jocel1 I've moved your test to doctrine/cache#231 and applied the fix, so I'll close this issue as `invalid` since it's not related to the ORM. Thanks for your contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5655