From 26295d5cf28177d3e3ef0f3de9541e4cdbcd8200 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 20 Dec 2021 14:46:20 +0200 Subject: [PATCH] Fixed `FlexIndex::call()` to return null instead of failing to call undefined method --- CHANGELOG.md | 1 + system/src/Grav/Framework/Flex/FlexIndex.php | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3efb28ba..724b617df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * Disabled pretty debug info for Flex as it slows down Twig rendering * Fixed Twig being very slow when template overrides do not exist * Fixed `UserObject::$authorizeCallable` binding to the user object + * Fixed `FlexIndex::call()` to return null instead of failing to call undefined method # v1.7.25 ## 11/16/2021 diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php index d3759787d..c433a080b 100644 --- a/system/src/Grav/Framework/Flex/FlexIndex.php +++ b/system/src/Grav/Framework/Flex/FlexIndex.php @@ -502,9 +502,13 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface } } else { $collection = $this->loadCollection(); - $result = $collection->{$name}(...$arguments); - if (!isset($cachedMethods[$name])) { - $debugger->addMessage("Call '{$flexType}:{$name}()' isn't cached", 'debug'); + if (\is_callable([$collection, $name])) { + $result = $collection->{$name}(...$arguments); + if (!isset($cachedMethods[$name])) { + $debugger->addMessage("Call '{$flexType}:{$name}()' isn't cached", 'debug'); + } + } else { + $result = null; } }