MDL-62907 Logging: Allow nulls on info, cases have been detected
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 17 Apr 2019 08:43:02 +0000 (10:43 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 17 Apr 2019 08:43:02 +0000 (10:43 +0200)
admin/tool/log/classes/helper/reader.php
admin/tool/log/store/standard/tests/store_test.php

index cc7e8b8..2e94774 100644 (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 {
index f2d0531..25963af 100644 (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.
      *