Closed (duplicate)
Project:
Aggregate cache
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Feb 2012 at 21:06 UTC
Updated:
6 Aug 2013 at 07:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
ralf.strobel commentedConfirmed. What I often see is that a generated file contains the exact same content twice.
I'm attaching an example. It seems like the source file (system.admin.css) was processed twice.
Comment #2
ralf.strobel commentedOk, I have identified the problem...
agrcache_build_aggregate_cache() uses two different hash functions to create $key and $uri. The key is based on the raw data structure ($files), while the aggregated file uri is based on the generated content ($data).
In some cases, it happens that two different $files structures lead to the same $data output. (In my case it was due to some simple rounding deviation in weight attributes, which made the file sets appear different.) At this point, two different values for $key point to the same $uri.
The problem then continues in agrcache_add_to_variable(), which uses array_merge_recursive() on the uri-keyed callback map array. And since the contained file entries are stored with numeric keys, array_merge will append them so that they appear multiple times (once for each key associated with the uri).
The first part seemed difficult to fix, and the behavior is actually correct, so instead I wrote a replacement for the add function, which only merges the arrays one level deep...
That has fully fixed the problem for me.
Comment #3
catchThe array merge bug was fixed in another commit some time ago, marking duplicate.