Skip to content

[6.x] Improve recursive behavior when using route data in computed values#11855

Merged
jasonvarga merged 4 commits into
statamic:6.xfrom
JohnathonKoster:improvement/prevent-recursion-when
Jul 10, 2026
Merged

[6.x] Improve recursive behavior when using route data in computed values#11855
jasonvarga merged 4 commits into
statamic:6.xfrom
JohnathonKoster:improvement/prevent-recursion-when

Conversation

@JohnathonKoster

Copy link
Copy Markdown
Contributor

This PR fixes the issue described in #11853. When a computed value triggers the routeData method and the collection has a structure, you can end up in an infinite loop when fetching the entry.

This PR wraps computed values in a Value object to defer their execution only when resolving routeData. This is accomplished with two new methods:

  • getComputedData
  • getValues

Both of these methods allow the caller to wrap computed callbacks in a Value object. These methods are now used in the existing computedData and values methods. This was done to keep the signatures of these methods the same.

It will still be possible to cause infinite loops, depending on what the user is doing. The changes in #11854 will help with those scenarios.

Comment thread src/Data/ContainsComputedData.php Outdated
@duncanmcclean duncanmcclean changed the title [5.x] Improve recursive behavior when using route data in computed values [6.x] Improve recursive behavior when using route data in computed values Jan 28, 2026
@duncanmcclean duncanmcclean changed the base branch from 5.x to 6.x January 28, 2026 17:30
…cursion-when

# Conflicts:
#	tests/Data/Entries/EntryTest.php
@jasonvarga jasonvarga merged commit 20ff8da into statamic:6.x Jul 10, 2026
19 checks passed
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.

3 participants