We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cd43069 commit 4fea2ccCopy full SHA for 4fea2cc
includes/CMB2_Utils.php
@@ -583,6 +583,10 @@ public static function unserialize_datetime( $date_value ) {
583
* @return DateTime|null
584
*/
585
public static function json_to_datetime( $json_string ) {
586
+ if ( ! is_string( $json_string ) ) {
587
+ return null;
588
+ }
589
+
590
$json = json_decode( $json_string );
591
592
// Check if json decode was successful
tests/test-cmb-utils.php
@@ -370,6 +370,7 @@ public function test_json_to_datetime() {
370
371
$this->assertEquals( $datetime, CMB2_Utils::json_to_datetime( $json ) );
372
$this->assertNull( CMB2_Utils::json_to_datetime( $evil_eval ) );
373
+ $this->assertNull( CMB2_Utils::json_to_datetime( [ $json ] ) );
374
}
375
376
0 commit comments