Live Preview on new entries breaks tags that rely on an entry id

未关闭
#15,734 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
laravel, php

调研方向

Start by tracing the Live Preview create flow introduced in #15648 and how the listed tags resolve entry context and structure; inspect the create preview route to understand why Pop out returns a 404. Reproduce with a new entry in a structured collection using the provided collection:next template, then check each listed tag and descendants()/in() behavior. Done means those tags handle unsaved entries without errors or unrelated results, and Pop out works from the create form.

由索引模型根据 Issue 内容生成。

描述

live preview
Bug description

Since #15648 (6.38.0) you can open Live Preview while creating an entry.

That entry isn't saved yet, so it has no id and isn't in the structure tree. Some core tags expect both and blow up in the preview:

  • collection:next / previous / older / newer: "Call to a member function collection() on null"
  • children, and nav with from="..." on structured collections: "Call to a member function pages() on null"
  • locales:count with all="true": "Call to a member function blueprint() on null"

Also:

  • descendants() and in() on the new entry return unrelated entries, because they query for entries without an origin.
  • Pop out on the create form opens a 404, because the create preview route is POST-only.
How to reproduce
  1. Add {{ collection:next }}{{ title }}{{ /collection:next }} to a template of a structured collection.
  2. Create Entry -> Live Preview.
  3. 💥
Logs

Environment
6.38.0
Installation

Fresh statamic/statamic site via CLI

Additional details

No response

主要语言
PHP
星标
4.9k
派生
647
平均合并
1 天 45 分钟
30 天内合并 PR
221

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

statamic/cms 的其他 Issue

查看 statamic/cms 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。