From 24db1f29fe930df680b6f79503f463ebb01e044e Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Mon, 20 Dec 2021 17:07:05 +0100 Subject: [PATCH] MDL-73420 core: make static cache compatible with PHP8.1 --- lib/classes/persistent.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/classes/persistent.php b/lib/classes/persistent.php index d9ec2bde40e..de9419c72ae 100644 --- a/lib/classes/persistent.php +++ b/lib/classes/persistent.php @@ -274,12 +274,13 @@ abstract class persistent { final public static function properties_definition() { global $CFG; - static $def = null; - if ($def !== null) { - return $def; + static $cachedef = []; + if (isset($cachedef[static::class])) { + return $cachedef[static::class]; } - $def = static::define_properties(); + $cachedef[static::class] = static::define_properties(); + $def = &$cachedef[static::class]; $def['id'] = array( 'default' => 0, 'type' => PARAM_INT,