-
Bug
-
Resolution: Fixed
-
Minor
-
3.11.4, 4.0
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE
-
MDL-73420-master -
Class core\persistent has a function
final public static function properties_definition() {
|
static $def = null;
|
that uses static variable for caching the properties definitions that is supposed to be cached for the current class. It works in PHP7 and PHP8.0, but it breaks in PHP8.1 and I personally find the new behavior more logical.
. When a method using static variables is inherited (but not overridden), the
|
inherited method will now share static variables with the parent method.
|
|
class A {
|
public static function counter() {
|
static $counter = 0;
|
$counter++;
|
return $counter;
|
}
|
}
|
class B extends A {}
|
|
var_dump(A::counter()); // int(1)
|
var_dump(A::counter()); // int(2)
|
var_dump(B::counter()); // int(3), previously int(1)
|
var_dump(B::counter()); // int(4), previously int(2)
|
|
This means that static variables in methods now behave the same way as
|
static properties.
|
- has been marked as being related by
-
MDL-76088 Blockslib uses static cache incorrectly, changes behavior under PHP 8.1
- Closed