Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Error accessing globals from non-Statamic 404 page

オープン
#14,167 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #15201 @wakqasahmed による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
laravel, php
領域
backend

調査の方向性

Start by reading resources/views/errors/404.antlers.html and tracing how SwapExceptionHandler hydrates the Cascade. Then investigate how Laravel renders Antlers error templates for Livewire requests that lack the X-Livewire header, including the suggested exception-rendering approach. Done means the 404 template can resolve its global values in this case without throwing BadMethodCallException.

索引モデルが issue の本文から書いたものです。

説明

cascade globals

I intermittently get this error in Laravel Nightwatch. Is this something that could be fixed with an update?

BadMethodCallException: Call to undefined method errorHeadline.
The Problem:

I was getting a BadMethodCallException: Call to undefined method errorHeadline in production, triggered by bots/scanners hitting the Livewire update endpoint directly (POST to /livewire-{hash}/update without the X-Livewire header).

The 404 error template (resources/views/errors/404.antlers.html) was pulling content from a 404 global set using the standard colon syntax:

{{ 404:error_headline }}
{{ 404:error_text }}
Root Cause:

Livewire registers its update route with only the web middleware group , it doesn't include Statamic's SwapExceptionHandler middleware, which is what hydrates the Cascade with global set data.

When Livewire's RequireLivewireHeaders middleware detects a request without the X-Livewire header, it calls abort(404). Laravel's default exception handler then renders the errors/404.antlers.html view through the Antlers engine, but without the Cascade being hydrated.

Without the Cascade, the Antlers runtime can't resolve 404 as a global set handle. It falls through to treating 404 as a tag name and attempts to call errorHeadline() as a method on Statamic\Tags\Tags via __call() — which throws BadMethodCallException.

The ?? (null coalescence) operator doesn't help either {{ 404:error_headline ?? 'fallback' }} still throws, because the exception happens during tag resolution before the fallback operator evaluates.

How to Reproduce:

From the browser console on any page with a valid session:

const token = decodeURIComponent(
  document.cookie.split('; ').find(c => c.startsWith('XSRF-TOKEN='))?.split('=')[1]
);
fetch('/livewire-YOUR_HASH_HERE/update', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'X-XSRF-TOKEN': token }
  // deliberately no X-Livewire header
}).then(r => r.text()).then(console.log)

You can find your Livewire endpoint hash with php artisan route:list | grep livewire.

Fix:

I hardcoded the content in the 404 template, removing all {{ 404:... }} references. The global set colon syntax ({{ handle:field }}) relies on the Cascade and can't be used safely in error templates that may be rendered outside Statamic's rendering pipeline.

Takeaway:

If you're using Antlers for your error templates (resources/views/errors/*.antlers.html), be aware that they can be rendered by Laravel's exception handler without Statamic's Cascade. Avoid global set references using the colon syntax ({{ global_handle:field }}). Either hardcode the values or use a Blade template with PHP to load globals via Statamic\Facades\GlobalSet::findByHandle().

I asked Claude if there's a fix? It suggested:

Statamic could hydrate the Cascade in the exception handler

Statamic's SwapExceptionHandler middleware is what sets up the Cascade for front-end routes. But routes outside Statamic's middleware stack (like Livewire's) use Laravel's default exception handler, which renders the Antlers 404 view without the Cascade. Statamic could register a global exception renderer (via Exceptions::render() in bootstrap/app.php or a service provider) that ensures the Cascade is hydrated before rendering any Antlers error template, regardless of which middleware stack the request went through.

Environment
Application Name: Statamic
Laravel Version: 12.53.0
PHP Version: 8.4.18
Composer Version: 2.9.5
Environment: local
Debug Mode: OFF
URL: website.test
Maintenance Mode: OFF
Timezone: America/New_York
Locale: en

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

Drivers
Broadcasting: log
Cache: redis
Database: sqlite
Logs: stack / single
Mail: smtp
Queue: sync
Session: redis

Storage
public/storage: NOT LINKED

Livewire
Livewire: v4.2.1

Statamic
Addons: 5
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.73.11 PRO

Statamic Addons
marcorieser/statamic-live-search: 3.1.1
marcorieser/statamic-livewire: 5.2.1
statamic/collaboration: 1.0.1
statamic/importer: 1.9.0
visuellverstehen/statamic-anchor-navigation: 1.0.0
主要言語
PHP
スター
4.9k
フォーク
647
平均マージ
1日 19時間
マージ済み PR(30日)
108

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

statamic/cms のほかの issue

statamic/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。