Skip to content

using {{? ?}} php tag, we cannot override existing variable. #11222

Open
@dadaxr

Description

@dadaxr

Bug description

In an antlers template creating a variable with a native php tag works fine :

{{? $newVar = "test"; ?}}
{{ newVar|dump }} {{# output "test" #}}

altering this newly created variable also works fine :

{{? $newVar = $newVar."_updated"; ?}}
{{ newVar|dump }} {{# output "test_updated" #}}

BUT, if the variable already exists in the cascade, we cannot alter it ...

For instance, if the "title" variable already exists in the cascade with the value "myTitle", it wont be updated...

{{? $title= "overridden title"; ?}}
{{ title|dump }} {{# still output "myTitle" instead of "overridden title" #}}

interestingly, if within the {{? ?}} tag itself, the override happens :

{{? $title= "overridden title"; dd($title}} ?}} {{# outputs "overriden title" #}}

note it's a project with statamic 3.4.11, but i'm pretty sure it also happens on the last versions...

How to reproduce

just use the above examples

Logs

No response

Environment

Environment
Application Name: Statamic leporc
Laravel Version: 9.52.7
PHP Version: 8.1.14
Composer Version: 2.5.1
Environment: local
Debug Mode: ENABLED
URL: leporc.localhost
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: smtp
Queue: sync
Session: file

Statamic
Addons: 2
Antlers: runtime
Stache Watcher: Disabled
Static Caching: Disabled
Version: 3.4.11 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions