Fixed a bug where 2 stats tags on same template could have cache issue - #5305
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.