Skip to content

Ensure result of Data hydration is handleable by the Cascade#27

Merged
marcorieser merged 1 commit intomainfrom
fix/cascade-hydration-on-null
Apr 16, 2026
Merged

Ensure result of Data hydration is handleable by the Cascade#27
marcorieser merged 1 commit intomainfrom
fix/cascade-hydration-on-null

Conversation

@marcorieser
Copy link
Copy Markdown
Owner

Fixes: #26

@marcorieser marcorieser merged commit 763d455 into main Apr 16, 2026
41 checks passed
@marcorieser marcorieser deleted the fix/cascade-hydration-on-null branch April 16, 2026 05:29
@jonathan-bird
Copy link
Copy Markdown

jonathan-bird commented Apr 16, 2026

@marcorieser The ?? collect() fix prevents the crash, but it changes the behavior compared to the initial page load. On a normal Route::statamic() request, FrontendController::route() passes null to cascadeContent(), the Cascade's null guard returns early, and page never gets set. With this fix, Livewire updates would set page to an empty collection instead.

A more consistent fix would be to resolve the content eagerly and skip withContent() when there's nothing:

protected function hydrateContent(): void
{
    $content = Data::findByRequestUrl(Livewire::originalUrl());

    if ($content) {
        Cascade::withContent($content);
    }
}

This matches exactly what happens on the initial page load - when there's no content entry for the URL, the Cascade just doesn't get content set at all.

@marcorieser
Copy link
Copy Markdown
Owner Author

marcorieser commented Apr 16, 2026

@jonathan-bird Yeah, I see that, but I don't want to hydrate the content if the Cascade is not used in the request. Need to think about it for a bit.

Once Jason merged this PR (statamic/cms#14502), I can remove ?? collect() and your case should be fixed, right?

@jonathan-bird
Copy link
Copy Markdown

@marcorieser Yeah I believe so, solves it further up the chain which is even better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HydrateCascadeByLivewireUrl crashes on Route::statamic() routes (null content)

2 participants