From 3347254e0d30c52005794ccbd4e7034d67199001 Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Thu, 28 Jul 2022 16:01:14 +0300 Subject: [PATCH] Fail-safe when update class cannot be correctly reconstructed or loaded. Previously, if the wrong base class name was written to the database, attempts to load update information could trigger a warning because there was no class_exists() check in the "updateBaseClass is set" branch. To fix that, I've moved the class_exists() closer to the place where the class name is actually used. StateStore will still fail to load a stored update if the class name is invalid, but without a PHP warning this time. The invalid stored update information should be overwritten the next time PUC checks for updates. --- Puc/v4p12/StateStore.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Puc/v4p12/StateStore.php b/Puc/v4p12/StateStore.php index b884181..04f334e 100644 --- a/Puc/v4p12/StateStore.php +++ b/Puc/v4p12/StateStore.php @@ -180,11 +180,11 @@ if ( !class_exists('Puc_v4p12_StateStore', false) ): $updateClass = null; if ( isset($state->updateBaseClass) ) { $updateClass = $this->getLibPrefix() . $state->updateBaseClass; - } else if ( isset($state->updateClass) && class_exists($state->updateClass) ) { + } else if ( isset($state->updateClass) ) { $updateClass = $state->updateClass; } - if ( $updateClass !== null ) { + if ( ($updateClass !== null) && class_exists($updateClass) ) { $this->update = call_user_func(array($updateClass, 'fromObject'), $state->update); } }