Issue Bug Closed

#107167Unable to use the default redis database #0 for the session cache

Rémi Payette 07/29/25, 19:46 updated 12/02/25, 13:58

Description

Since #104451 has been implemented, we can use the same redis database for all caches using prefixes.

Since redis doesn’t support databases on multi-core redis server, I was going to use the default database 0 with prefixes for all caches.
https://docs.typo3.org/permalink/t3coreapi:caching-backend-redis-example

It works except for the session cache :
cms-core/Classes/Session/Backend/RedisSessionBackend.php

function validateConfiguration() permits that :

            if ($this->configuration['database'] < 0) {
                throw new \InvalidArgumentException(
                    'The specified database "' . $this->configuration['database'] . '" must be greater or equal than zero.',
                    1481270923
                );
            }

but later,
function initializeConnection()

        if (isset($this->configuration['database'])
            && $this->configuration['database'] > 0
            && !$this->redis->select($this->configuration['database'])
        ) {
            throw new \RuntimeException(
                'The given database "' . $this->configuration['database'] . '" could not be selected.',
                1481270987
            );
        }

is there some logic I didn’t understood or is it a forgotten edge case ? ( > 0 instead of >= 0 )

Reviews 3

History 710

  1. Markus Klein commented <span data-processor="relativetime" data-value="2025-07-30T11:53:24+00:00" > 07/30/25, 11:53 </span>

    This bug obviously dates back to the original feature.

  2. Markus Klein commented and changed category assigned to Markus Klein priority Should have Must have Complexity trivial <span data-processor="relativetime" data-value="2025-07-30T12:02:38+00:00" > 07/30/25, 12:02 </span>

    @nalmar please review the patch above and vote. Thank you.

  3. Rémi Payette commented <span data-processor="relativetime" data-value="2025-07-30T15:32:42+00:00" > 07/30/25, 15:32 </span>

    @liayn I’m new to Gerrit but I think I did what you asked

  4. Markus Klein commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-08-04T07:20:08+00:00" > 08/04/25, 07:20 </span>

    Applied in changeset commit:e1e0ce8e3059d1910dd6f3ed8443c27b6c6d12d1.