-
-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR 10226 introduced bug with nav tag when using select #10571
Comments
The The following will restore the behavior (but will defer to the Core team on if this is an actual bug, or not): <ul>
{{ nav:main select="title|url|id|entry_id" }}
<li>{{ looper }}<br>{{ id }}</li>
{{ /nav:main }}
</ul> |
Thanks John, that makes sense and can confirm. With that being the case, it would make more sense for the context to be a more accurate representation of what is actually available - not sure if that is possible with the way the internals work within Antlers. Just taking a step back to a bigger picture idea, if I select three properties, then realistically I should only see those selected properties, not properties that existed from an earlier iteration. Or even if scoping the selected variables would overcome that - but still would leave ambiguity as to which variable to use. |
The values you receive are merged with the outer scope, and made available within the More specifically, it gets injected here: https://github.com/statamic/cms/blob/5.x/src/Structures/AugmentedPage.php#L40 If we change the return value, we can see that's the value that gets used: Hope this helps a bit! |
Yeah it makes sense what it is doing and not arguing with that at all, but from a DX perspective, it adds ambiguity given a variable is available when it wasn't part of the select request. In SQL terms, if I only request three columns with a select statement, that's all I get, and all I would expect. In a perfect world, if I use a select param for three specific params, then I should only have access to those three params - which I do if I use the It would make more sense if that scope was almost there by default within a scoped block like a loop - and getting outer scope required an extra step, rather than the other way around. But I know that's a major thing, with a big flow-on effect for everyone's sites. |
I agree with what you're saying, and it's definitely possible. Maybe as a new param like Could also make something more general to restrict scopes in other places to "only" certain values without inheriting items from the outer scopes |
That sounds awesome for sure! I've been caught out with loops before for this reason - so try to use |
Bug description
When using the
select
param on thenav
tag in 5.19, it appears keys get cached internally across multiple calls especially when used within a loop.How to reproduce
Reproducible with this repo:
https://github.com/martyf/statamic-issue-bulk-augmentor
Within a
nav
tag, the code is calling a Tag that returns the context'sentry_id
.On 5.19, you'll see the "Expected" results are not returned - the
entry_id
is the same for every loop.Change the composer.json
statamic/cms
version to 5.18 and you'll see theentry_id
be correct for every loop.On 5.19, if the changes to
src/Data/BulkAugmentor.php
from #10226 are reverted, the issue disappears (however I'm not sure what impact that has on the PR's actually purpose)This is only when the
select
param is used - seeresources/views/layout.antlers.html
. Remove theselect
param on 5.19 and the Actual is correct.Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: