Fixed Pages::instances() returning null values when using Flex Pages [#2889]

This commit is contained in:
Matias Griese
2020-04-23 10:41:42 +03:00
parent 7d4aef0f3b
commit 01b0b1602b
2 changed files with 12 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
* Support symlinks when saving `File`
1. [](#bugfix)
* Fixed flex objects with integer keys not working [#2863](https://github.com/getgrav/grav/issues/2863)
* Fixed `Pages::instances()` returning null values when using `Flex Pages` [#2889](https://github.com/getgrav/grav/issues/2889)
* Fixed user avatar creation for new `Flex Users` when using folder storage
* Fixed `Trying to access array offset on value of type null` PHP 7.4 error in `Plugin.php`
* Fixed Gregwar Image library using `.jpeg` for cached images, rather use `.jpg`

View File

@@ -748,12 +748,20 @@ class Pages
$instance = $this->index[$path] ?? null;
if (\is_string($instance)) {
$instance = $this->directory ? $this->directory->getObject($instance, 'flex_key') : null;
if ($instance && $this->fire_events && method_exists($instance, 'initialize')) {
$instance->initialize();
if ($instance) {
if ($this->fire_events && method_exists($instance, 'initialize')) {
$instance->initialize();
}
} else {
/** @var Debugger $debugger */
$debugger = $this->grav['debugger'];
$debugger->addMessage(sprintf('Flex page %s is missing or broken!', $instance), 'debug');
}
}
$this->instances[$path] = $instance;
if ($instance) {
$this->instances[$path] = $instance;
}
return $instance;
}