Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.7
-
MOODLE_37_STABLE
-
MOODLE_37_STABLE
-
MDL-62907-master -
Description
The standard log table (mdl_logstore_standard_log) uses an 'other' field to store arbitrary data provided by events. This field is currently serialised using PHP serialisation, for example:
'a:2:{s:7:"modname";s:12:"htmlactivity";s:4:"info";s:11:"default: id";}'
|
PHP serialisation is not widely supported, whereas JSON serialisation is very well supported. For example, if you are writing a database report and you want to get the info field out of that object serialized into 'other', here is how you can do it using Postgres with PHP serialisation (this is a bodge job and doesn't handle some edge cases):
regexp_replace(other, '^.*?"info";s:[0-9]+:"(.*?)".*$', E'\\1')
|
But here is how you could do it if the data were stored in JSON format:
other::json->'info'
|
Changing the log format at this point could cause problems for integrations, but it might be worth having an admin setting - which could default to true for new installations, false for existing ones - to use JSON format in this field. The code that deserializes could support both formats ('a:' or 'N;' at the start of the field identifies PHP format) so that it still works OK if you switch it on/off.
I don't think I have time to write this at the moment, sadly, but am creating a tracker entry in case of interest from others!