Issue Bug Closed

#109594Caching Mechanism in GreedyDatabaseBackend don't support heterogeneous data

Christopher Kussin 04/16/26, 07:30 updated 11/11/26, 21:20

Description

The caching mechanism changed in 13.4.28 is flawed.
It dosen’t support when in one request elements from different pids are present or if in the list at least one element is not yet resolved.
it will return the first element that is already in the cache.
but if there is at least one element in the list that is not yet resolved it will be discarded

i adapted the GreedyDatabaseBackend like this

    protected function getRowsFromCache(string $cacheIdentifier, string $tableName, array $uids, Context $context): ?array
    {
        // already in cache?
        if ($this->runtimeCache->has($cacheIdentifier)) {
            // deliver
            return $this->runtimeCache->get($cacheIdentifier);
        }

        // get all the cache identifiers for the uids
        $caches = [];
        foreach ($uids as $uid) {
            // get the pointer cache
            $cacheIdentifierPointer = $this->createRuntimeCacheIdentifier($tableName, [$uid], $context, 'pointer');

            // no cache for this element? this has to be resolved !!
            if(!$this->runtimeCache->has($cacheIdentifierPointer))
                return null;

            // otherwise get the identifier
            $cacheIdentifier = $this->runtimeCache->get($cacheIdentifierPointer);
            $caches[] = $cacheIdentifier;
        }

        // no cache for any of the uids?
        // resolve it
        if(empty($caches))
            return null;

        // get the actual cache entries
        $result = [];
        foreach (array_unique($caches) as $cacheIdentifier){
            if ($this->runtimeCache->has($cacheIdentifier)) {
                $result = [
                    ...$result,
                    ...($this->runtimeCache->get($cacheIdentifier) ?? [])
                ];
            }
        }

        return empty($result) ? null : $result;
    }

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 6

  1. Patrick Broens commented <span data-processor="relativetime" data-value="2026-04-17T10:39:57+00:00" > 04/17/26, 10:39 </span>

    I can confirm the caching mechanism is flawed in 13.4.28

    I’m using the record-transformation data processor on a content element with IRRE. In the IRRE table there is a field of the type “group” where “pages” are allowed. When looking at the frontend, some of these pages have miraculously disappeared. I could also track it down to the method “getRowsFromCache” in the GreedyDatabaseBackend.

    The fix of Christopher works for me.

  2. Jochen Rieger commented <span data-processor="relativetime" data-value="2026-05-26T10:03:08+00:00" > 05/26/26, 10:03 </span>

    Thanks a lot for taking care of this one.

    I also stumbled across a very visible issue (most likely) caused by the change introduced in `13.4.28`:

    Preview of “Insert Records” elements in the Page module. The Page module preview only shows a subset of selected records that lives on one pid, while the edit form still lists all selected records.

    Haven’t tested the fix just yet, but I guess it might mitigate / fix the behavior as well.

    Ping me if you need more info on how to reproduce this, etc. … if further input is helpful.

  3. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-11T21:20:22+00:00" > 11/11/26, 21:20 </span>

    this has been fixed today with #110663, however no changes for 13 planned, only 14.3+