Bolt: Changing themes isn't invalidating cached Twig

Created on 7 Nov 2016  Â·  5Comments  Â·  Source: bolt/bolt

Reproduction

  • Base install
  • Add some content
  • Change to a theme like Solid State

image

Workaround

  • Flush cache

Reported in Slack by @eduardomart

bug

Most helpful comment

…and found it. It has been with us since 3.0.0.

Twig creates a hash based on the full path of the file, but in 3.x we virtualise the file system, and so rather than the hash being created on /{path}/public/theme/{theme name}/index.twig it is created on theme://index.twig (actually just index.twig, I used the mount point syntax for clarity) … so Twig assumes it is the same file and uses the cached version.

Removing as a blocker … getting some sleep …and I will have a chat with @CarsonF about bright ideas to resolve this.

All 5 comments

This seems to be caused by a change in Twig 1.24+ … reverting to 1.23.0 doesn't cause it to occur.

Edit: I was a little too enthusiastic in my testing, it indeed occurs with 1.23.0+

Also present in Bolt 3.1.6

…and found it. It has been with us since 3.0.0.

Twig creates a hash based on the full path of the file, but in 3.x we virtualise the file system, and so rather than the hash being created on /{path}/public/theme/{theme name}/index.twig it is created on theme://index.twig (actually just index.twig, I used the mount point syntax for clarity) … so Twig assumes it is the same file and uses the cached version.

Removing as a blocker … getting some sleep …and I will have a chat with @CarsonF about bright ideas to resolve this.

Yeah, this doesn't qualify as a blocker to me. Glad you caught it, though.. I recall bumping into this behaviour before, but never enough to realise what was going on, other that "huh, something strange" that passes. :-)

Also experienced first a week ago here but felt like Bob... :)

Was this page helpful?
0 / 5 - 0 ratings