MDL-62907 Logging: Allow nulls on info, cases have been detected

This commit is contained in:
Eloy Lafuente (stronk7) 2019-04-17 10:43:02 +02:00
parent 0423ed4a0f
commit 65453b9861
2 changed files with 5 additions and 1 deletions

View File

@ -73,7 +73,7 @@ trait reader {
* @param string $other Other value
* @return mixed Decoded value
*/
public static function decode_other(string $other) {
public static function decode_other(?string $other) {
if ($other === 'N;' || preg_match('~^.:~', $other)) {
return unserialize($other);
} else {

View File

@ -374,6 +374,10 @@ class logstore_standard_store_testcase extends advanced_testcase {
$this->assertEquals($value, \logstore_standard\log\store::decode_other(json_encode($value)));
}
public function test_decode_other_with_wrongly_encoded_contents() {
$this->assertSame(null, \logstore_standard\log\store::decode_other(null));
}
/**
* List of possible values for 'other' field.
*