MDL-72339 core_availability: Unsafe to use format_string in description

The availability condition get_description method is called while
gathering data for the modinfo object. As such it is not safe to
call other functions which might rely on modinfo, such as format_string
(if using filters which access modinfo).

This change provides a mechanism to call format_string later, and also
a general callback to do other stuff later as well if needed. It uses
the same approach already taken to make activity names work correctly
in the availability_condition class.
This commit is contained in:
sam marshall
2021-10-06 11:28:26 +01:00
parent 1a9bee69e6
commit 4dd7f2ac54
16 changed files with 275 additions and 19 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ class info_module extends info {
// We cannot access $cm->name as a property at this point, because this
// code may itself run in response to the $cm->name property access, and
// PHP magic function properties do not allow recursion (because PHP).
return '<AVAILABILITY_CMNAME_' . $this->cm->id . '/>';
return condition::description_cm_name($this->cm->id);
}
protected function set_in_database($availability) {