statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.79k stars 517 forks source link

Glide tag throws error when used inside nocache tag (using replicator) #9456

Closed j-jalving closed 7 months ago

j-jalving commented 7 months ago

Bug description

After updating Statamic I got a strstr(): Argument #1 ($haystack) must be of type string, array given error on all my pages. After investiging this piece of code triggered it:

{{ nocache }}
  {{ footer:partners sort="random" limit="1" }}
    {{ glide:logo width="200" format="png" }}
      <img src="{{ url }}" />
    {{ /glide:logo }}
  {{ /footer:partners }}
{{ /nocache }}

footer is a global with a partners replicator inside it. It seems that the error only occurs when using a replicator and when the glide tag is inside a nocache tag.

How to reproduce

  1. Create a global variable with a replicator field containing an asset field that accepts a single image.
  2. In your antlers template, load an asset using a glide tag like this:
    {{ footer:partners sort="random" limit="1" }}
    {{ glide:logo }}
    <img src="{{ url }}" />
    {{ /glide:logo }}
    {{ /footer:partners }}
  3. This works, but when adding {{ nocache }} tags around it an error is thrown:
    {{ nocache }}
    {{ footer:partners sort="random" limit="1" }}
    {{ glide:logo }}
      <img src="{{ url }}" />
    {{ /glide:logo }}
    {{ /footer:partners }}
    {{ /nocache }}

Logs

No response

Environment

Environment
Application Name: ***
Laravel Version: 10.43.0
PHP Version: 8.3.1
Composer Version: 2.6.4
Environment: local
Debug Mode: ENABLED
URL: ***
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: ses
Queue: sync
Session: file

Localization
Installed: en, nl
LaravelLang\Attributes\Plugin: 2.9.4
LaravelLang\HttpStatuses\Plugin: 3.8.0
LaravelLang\Lang\Plugin: 12.24.2
Protected Locales: en, nl
Publisher Version: 14.7.1

Sentry
Enabled: MISSING DSN
Environment: local
Laravel SDK Version: 4.2.0
PHP SDK Version: 4.5.0
Release: NOT SET
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: NOT SET
Sample Rate Profiling: NOT SET
Send Default PII: DISABLED

Statamic
Addons: 9
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.47.0 PRO

Statamic Addons
aerni/livewire-forms: 8.1.0
aerni/social-links: 3.1.0
dryven/faviconator: 1.2.2
gerttimmerman/statamic-zapier: dev-main
j-jalving/statamic-autograph: 1.3.0
jonassiewertsen/statamic-livewire: 2.12.0
rias/statamic-redirect: 3.6.1
statamic/seo-pro: 5.4.1
swiftmade/statamic-clear-assets: 2.0.1

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

Runtime (default)

Additional details

No response

jasonvarga commented 7 months ago

After updating Statamic

What version were you on?

j-jalving commented 7 months ago

4.46.0

j-jalving commented 7 months ago

Updating to 4.48.0 seems to have fixed this issue