This commit is contained in:
David Monllaó 2019-04-17 11:16:44 +02:00
commit 6289f6afe3
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.
*