Collection blueprints served from an addon directory fail with "Undefined array key 0"
维护者通常 1 天内回复
评估
调研方向
Start in BlueprintRepository.php at makeBlueprintFromFile(), and compare its $additionalNamespaces lookup with how filesIn() normalizes collections/people to collections.people. Follow Collection::entryBlueprints() to see the call path. Work on this is already under way in PR #15881, so check that PR before starting. Done means a regression test for an addon-registered collection blueprint directory passes.
由索引模型根据 Issue 内容生成。
描述
Bug description
An addon that registers a collection blueprint directory with Blueprint::addNamespace('collections.people', $dir) (what AddonServiceProvider does with $blueprintNamespace) cannot have that collection's entry blueprints loaded.
Collection::entryBlueprints() calls Blueprint::in('collections/people'). filesIn() normalizes / to . and finds the addon directory, but then makeBlueprintFromFile($file, 'collections/people') looks the slash form up in $additionalNamespaces (keyed with dots), misses, and falls through to getNamespaceAndHandleFromPath() for a path outside every configured directory: ErrorException: Undefined array key 0 at BlueprintRepository.php:362 (6.40.0).
Expected: the blueprint loads, as it does through filesIn().
How to reproduce
- Register
Blueprint::addNamespace('collections.people', '/path/with/people.yaml'). - Call
Collection::make('people')->entryBlueprints(). - Observe
ErrorException: Undefined array key 0.
Reproduced on 6.40.0 and on current 6.x (9d20aef).
Logs
ErrorException: Undefined array key 0 at BlueprintRepository.php:362
Environment
Statamic: 6.40.0 (also current 6.x, 9d20aef)
Found by reading the package source and reproducing it in the package's own test suite, not on a running site, so the full php please support:details output is not available.
Installation
Other (please explain): reproduced in the statamic/cms test suite, with an addon-style namespace registration.
Additional details
Fix: normalize the namespace in makeBlueprintFromFile() the same way filesIn() does. A pull request with a regression test follows.
- 主要语言
- PHP
- 星标
- 4.9k
- 派生
- 647
- 平均合并
- 1 天 45 分钟
- 30 天内合并 PR
- 221
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
statamic/cms 的其他 Issue
-
forms ui
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
accessibility
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
antlers
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
Nav: link to the site root with an anchor (/#section) gets is_parent on every page可能已有人在做 @duncanmcclean 今天认领。 未关闭navigations
难度 2/5 1-3 小时 新手友好度 35/100
维护者通常 1 天内回复
-
Multiple Choice and Checkboxes no longer offer "Inline", but the default views still use it可能已有人在做 @duncanmcclean 今天认领。 未关闭forms
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
sync-en
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
taskforcesh/bullmq#5238 ·
维护者通常 1 天内回复
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects it可能已有人在做 @bfs2021 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
Automattic/jetpack#55517 ·
维护者通常 1 天内回复