Review main Abandoned

93013[BUGFIX] Add missing error handling for Redis commands in RedisBackend

Rico Sonntag CR 0 V -1 Hard +261 −2 updated 10/02/26, 11:02

Commit message

Redis commands like sMembers(), keys() and sUnion() can return false
when they fail (e.g. due to permission errors like NOPERM). The
RedisBackend does not check for these failures, causing the false
return value to propagate into array operations (array_diff, foreach),
resulting in TypeErrors that obscure the actual Redis error.

For example, when a Redis user lacks the 'sunion' permission, the
error manifests as:
  array_diff(): Argument #1 ($array) must be of type array, false given

This patch adds error handling to all Redis command calls that can
return false: sMembers() in set(), remove(), findIdentifiersByTag(),
flushByTag(), collectGarbage(); keys() in flush(), collectGarbage();
and sUnion() in removeIdentifierEntriesAndRelations().

Each failure is now logged as a warning with the Redis error message
from getLastError(), and the method either returns early or continues
with a safe default (empty array).

Review

  • Code review CR 0
  • Verified V -1
    • core-ci -1 CI

Issues 1

Files 2

Review log 1825

  1. Rico Sonntag uploaded patch set 1 02/26/26, 12:37

  2. core-ci voted on patch set 1 V -1 02/26/26, 13:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96909

  3. Markus Klein commented on patch set 1 02/26/26, 13:57

    RedisBackend.php:266

    the empty can now be removed and a simple `if ($existingTags)` is sufficient

    RedisBackend.php:328

    Let's move this into a dedicated log function, so we do not repeat the getLastError call all over the place.
  4. Rico Sonntag commented on patch set 1 03/02/26, 08:18

    Note: This fix is also needed for the 13.4 branch. The previous backport attempt (change 93014) was abandoned due to an incorrect relation chain. A proper cherry-pick backport should be created after this change is merged.
  5. Rico Sonntag uploaded patch set 2 V -1 03/02/26, 08:31

  6. Rico Sonntag commented on patch set 2 03/02/26, 08:34

    Patch Set 2: Addressed review feedback - extracted logRedisCommandFailure() helper method, simplified if (!empty($existingTags)) to if ($existingTags). Also fixed php_unit_test_case_static_method_calls CGL warning (self::once() -> $this->once()).
  7. Rico Sonntag commented on patch set 2 03/02/26, 08:36

    RedisBackend.php Reply

    Done

    RedisBackend.php Reply

    Done
  8. core-ci voted on patch set 2 V +1 03/02/26, 08:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97088

  9. Markus Klein updated the commit message in patch set 3 V +1 03/02/26, 09:44

  10. core-ci voted on patch set 3 V +1 03/02/26, 09:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97092

  11. Markus Klein commented on patch set 3 03/03/26, 14:46

    thanks for the update, just minor remarks. But should we do the same for the RedisSessionBackend?

    RedisBackend.php:480

    protected is better for extensibility
  12. Rico Sonntag uploaded patch set 4 V +1 03/03/26, 18:04

  13. Rico Sonntag uploaded patch set 5 03/03/26, 18:05

  14. Rico Sonntag commented on patch set 5 03/03/26, 18:05

    Reply

    Good point. The RedisSessionBackend uses different Redis methods (get, set, del, scan, mGet) and would benefit from similar error handling. I'll address that in a separate change.

    RedisBackend.php Reply

    Done

    RedisBackend.php Reply

    Done
  15. core-ci voted on patch set 4 V -1 03/03/26, 18:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97207

  16. core-ci voted on patch set 5 V -1 03/03/26, 18:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97208

  17. Rico Sonntag uploaded patch set 6 V -1 03/03/26, 19:30

  18. Rico Sonntag commented on patch set 6 03/03/26, 19:46

    RedisSessionBackend follow-up created: https://review.typo3.org/c/Packages/TYPO3.CMS/+/93048
  19. core-ci voted on patch set 6 V +1 03/03/26, 20:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97217

  20. Markus Klein voted on patch set 6 CR +1 V +1 03/09/26, 08:52

  21. Sven Liebert voted on patch set 6 CR +1 V +1 03/10/26, 14:13

  22. Benni Mack updated the commit message in patch set 7 CR +1 V +1 04/22/26, 06:41

  23. core-ci voted on patch set 7 V -1 04/22/26, 09:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100761

  24. Benni Mack abandoned the change 10/02/26, 09:37

  25. Markus Klein commented on patch set 7 10/02/26, 11:02

    Unresolved

    @benni@typo3.org Abandon is wrong IMO. This patch is about cache-backend, the other one about session-backend