Skip to content

[Cache] "Trying to access array offset on value of type bool" warning with RedisAdapter�?#46384

Closed
@mbabker

Description

@mbabker

Symfony version(s) affected

5.4.8

Description

Quite routinely in our Sentry logs, we're getting the noted warning being captured when trying to write the result of a query to Redis for caching. I'm only including the part of the stack trace from our repository's call to Doctrine\ORM\AbstractQuery::getResult() as the rest isn't really relevant:

ErrorException: Warning: Trying to access array offset on value of type bool
#30 /vendor/symfony/cache/Traits/RedisTrait.php(562): Symfony\Component\Cache\Adapter\RedisAdapter::pipeline
#29 /vendor/symfony/cache/Traits/RedisTrait.php(499): Symfony\Component\Cache\Adapter\RedisAdapter::doSave
#28 /vendor/symfony/cache/Adapter/AbstractAdapter.php(167): Symfony\Component\Cache\Adapter\AbstractAdapter::commit
#27 /vendor/symfony/cache/Traits/AbstractAdapterTrait.php(276): Symfony\Component\Cache\Adapter\AbstractAdapter::save
#26 /vendor/doctrine/dbal/src/Connection.php(1108): Doctrine\DBAL\Connection::executeCacheQuery
#25 /vendor/doctrine/dbal/src/Connection.php(1026): Doctrine\DBAL\Connection::executeQuery
#24 /vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(31): Doctrine\ORM\Query\Exec\SingleSelectExecutor::execute
#23 /vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(325): Doctrine\ORM\Query::_doExecute
#22 /vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(1188): Doctrine\ORM\AbstractQuery::executeIgnoreQueryCache
#21 /vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(1142): Doctrine\ORM\AbstractQuery::execute
#20 /vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(878): Doctrine\ORM\AbstractQuery::getResult

ORM 2.12.2 and DBAL 3.3.6 are in use here, with ext/redis at 5.3.6 and Redis 6.x servers.

How to reproduce

I'm not able to recreate it in any environment but our production system, but the calling code in our app isn't anything crazy repository class:

return $this->createQueryBuilder('alert')
    ->leftJoin('alert.attachments', 'attachment')
    ->where('alert.published_from <= :now')
    ->andWhere('alert.published_to >= :now')
    ->orderBy('alert.published_from')
    ->addOrderBy('alert.title')
    ->setParameter('now', new \DateTimeImmutable('now', new \DateTimeZone('UTC')))
    ->getQuery()
    ->enableResultCache(600, 'active_alerts')
    ->getResult();

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