Skip to content

Fixed a bug where 2 stats tags on same template could have cache issue - #5305

Merged
TomJaeger merged 2 commits into
stats-status-filterfrom
stats-status-bugfix-cache
Jun 3, 2026
Merged

TomJaeger merged 2 commits into
stats-status-filterfrom
stats-status-bugfix-cache

Conversation

@robinsowell

@robinsowell robinsowell commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Put a stats tag on the template and specify the channel. Put a second tag and don't specify the channel. The results of the first tag will be duplicated in the second, despite the unlimited tag having more entries etc.

The issue was request-local state bleed. The first channel-filtered {exp:stats channel="blog"} tag was overwriting shared ee()->stats values, so the later plain {exp:stats} reused the blog values.

Note- had to tweak the test file as well, because it assumed ee()->stats->statdata() would have an argument and now it doesn't. So needed to allow for that.

Put a stats tag on the template and specify the channel.  Put a second tag and don't specify the channel.  The results of the first tag will be duplicated in the second, despite the unlimited tag having more entries etc.
This PR fixes the stats test mock so it matches the real EE_Stats::statdata() API.

The updated Stats module calls ee()->stats->statdata() with no argument to get the full stats array. Production already supports that, but the new test mock required a key every time. Because of that, the status filter tests would fail before they reached the behavior they were meant to verify.

The mock now accepts an optional key:

with no key, it returns the full mock stats array
with a key, it returns that value or false
This keeps the test double aligned with production behavior and lets the stats status filter tests exercise the actual code path.
@TomJaeger
TomJaeger merged commit 7835af8 into stats-status-filter Jun 3, 2026
1 check passed
@TomJaeger
TomJaeger deleted the stats-status-bugfix-cache branch June 3, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants