getgrav / getgrav/grav-plugin-admin
Extending a blueprint causes fatal error
- Dominant language
- PHP
- Stars
- 377
- Forks
- 225
- Avg merge
- 11h 51m
- Merged PRs (30d)
- 4
Description
**Expected Behavior**
A user can extend a plugin's blueprints if the plugin has enabled this behavior.
**Actual Behavior**
After using `extends@` with the expected structure, the server refuses to restart.
**Specifications**
Grav v1.7.49.1 + Admin v1.10.49, Windows 10 x64, PHP v8.2.29 x64
**Steps to Reproduce the Problem**
[Repository with file differences](https://github.com/OleVik/grav-admin-blueprints-crash/commits/main/)
1. Downloaded [Grav v1.7.49.1 + Admin v1.10.49](https://getgrav.org/download/core/grav-admin/1.7.49.1) and unzipped it
2. Ran `php bin/grav server` using PHP v8.2.29, and created an Admin-user
3. Added `public $features = ['blueprints' => 10,];` in [`user/plugins/markdown-notices/markdown-notices.php`](https://github.com/OleVik/grav-admin-blueprints-crash/blob/main/user/plugins/markdown-notices/markdown-notices.php#L37) per [#1804](https://github.com/getgrav/grav-plugin-admin/issues/1804#issuecomment-579279995)
4. Modified [`user/plugins/markdown-notices/blueprints.yaml`](https://github.com/OleVik/grav-admin-blueprints-crash/blob/main/user/plugins/markdown-notices/blueprints.yaml) to import properties:
```yaml
form:
validation: strict
import@:
type: options
context: blueprints://plugins/markdown-notices
```
5. Added [`user/plugins/markdown-notices/blueprints/plugins/markdown-notices/options.yaml`](https://github.com/OleVik/grav-admin-blueprints-crash/blob/main/user/plugins/markdown-notices/blueprints/plugins/markdown-notices/options.yaml) with the original fields:
```yaml
form:
fields:
enabled:
type: toggle
label: PLUGIN_ADMIN.PLUGIN_STATUS
highlight: 1
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
built_in_css:
type: toggle
label: PLUGIN_MARKDOWN_NOTICES.USE_BUILT_IN_CSS
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
base_classes:
type: selectize
label: PLUGIN_MARKDOWN_NOTICES.BASE_CLASSES
size: large
placeholder: PLUGIN_MARKDOWN_NOTICES.BASE_CLASSES_PLACEHOLDER
help: PLUGIN_MARKDOWN_NOTICES.BASE_CLASSES_HELP
classes: fancy
validate:
type: string
level_classes:
type: selectize
label: PLUGIN_MARKDOWN_NOTICES.LEVEL_CLASSES
size: large
placeholder: PLUGIN_MARKDOWN_NOTICES.LEVEL_CLASSES_PLACEHOLDER
help: PLUGIN_MARKDOWN_NOTICES.LEVEL_CLASSES_HELP
classes: fancy
validate:
type: commalist
```
6. Cleared cache with `php bin/grav clearcache`, restarted server, and forced browser refresh
7. Options show up as expected, and persist without error past a cleared cache
8. Added [`user/blueprints/markdown-notices/options.yaml`](https://github.com/OleVik/grav-admin-blueprints-crash/blob/main/user/blueprints/plugins/markdown-notices/options.yaml) to override a property of a field by [extending the base type](https://learn.getgrav.org/17/forms/blueprints/advanced-features#extending-base-type-extendsat):
```yaml
extends@:
type: options
context: blueprints://plugins/markdown-notices
form:
fields:
enabled:
label: Modified label
```
9. Verified that the label shows the changed text
10. Stopped server and cleared cache
11. Trying to start server again now results in a fatal error:
```
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in ...\grav-admin-blueprints-crash\vendor\rockettheme\toolbox\ResourceLocator\src\UniformResourceLocator.php on line 271
```
Referring to [this line](
https://github.com/rockettheme/toolbox/blob/1.6.5/ResourceLocator/src/UniformResourceLocator.php#L271) in `RocketTheme/Toolbox`, which contains
```php
$uri = (string)preg_replace('|\\\\|u', '/', $uri);
```
Contributor guide
Research direction
Start with user/blueprints/plugins/markdown-notices/options.yaml, the plugin blueprints.yaml, and the reproduction steps using php bin/grav server and php bin/grav clearcache. Trace the restart failure at vendor/rockettheme/toolbox/ResourceLocator/src/UniformResourceLocator.php line 271 while the extends@ context is active. Done means the overridden label remains effective and the server restarts without the memory-exhaustion fatal error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100