cms
cms copied to clipboard
Bard fields augment multiple times with runtime Antlers parser
Bug description
When using the runtime Antlers parser I'm seeing Bard fields being augmented/rendered multiple times, despite only being output once. I'm checking this by calling dump in the Statamic\Fieldtypes\Bard\Augmentor::convertToHtml method.
With the regex parser that method is only called once per output, with the runtime parser it's called three times.
Given that Bard fields can contain a large amount of content when used as page builders etc. this could have a significant performance impact.
How to reproduce
- Create a Bard field, add some content and output it in a template.
- Log the number of times the Bard Augmentor is run.
Logs
No response
Versions
Statamic 3.3.5 Pro Laravel 8.83.7 PHP 8.1.2
Installation
Starter Kit using via CLI
Antlers Parser
runtime (new)
Additional details
No response
This is something I've been looking into with this work here: https://github.com/statamic/cms/pull/5783
Internally there are a number of places where a value may be resolved to determine what to do with the data:
- An existence check: to help decide if something should be executed as a tag or variable
- Checking for query builder instances to decide if they should be intercepted and ran through the
querytag - Finally when resolving the value to actually produce output
I'll look into other improvements while that PR is reviewed/discussed 👍