]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 27 Aug 2020 14:19:15 +0000 (16:19 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 27 Aug 2020 14:20:24 +0000 (16:20 +0200)
* PHP-7.4:
  Don't assert when comparing uninit DateTimeZone objects

1  2 
ext/date/php_date.c
ext/date/tests/DateTimeZone_compare_basic1.phpt

index 43aa2ba637e6a5a4d752408d756046154d4c1d86,66812cbc22ca90401d3e9e07e75566350a91ee0f..e32874505161239828d6a841498d45f22c77a077
@@@ -1882,7 -2390,10 +1882,10 @@@ static int date_object_compare_timezone
        o1 = Z_PHPTIMEZONE_P(tz1);
        o2 = Z_PHPTIMEZONE_P(tz2);
  
-       ZEND_ASSERT(o1->initialized && o2->initialized);
+       if (!o1->initialized || !o2->initialized) {
 -              php_error_docref(NULL, E_WARNING, "Trying to compare uninitialized DateTimeZone objects");
++              zend_throw_error(NULL, "Trying to compare uninitialized DateTimeZone objects");
+               return 1;
+       }
  
        if (o1->type != o2->type) {
                php_error_docref(NULL, E_WARNING, "Trying to compare different kinds of DateTimeZone objects");
index b4e8d76cc2deb4d140daf153f87e169c9fedaffa,3ec6174fa819ea078b95c7b88f2849492260abd9..27cd7e820870264c44fff8445aa036b074451483
@@@ -29,6 -29,17 +29,21 @@@ function compare_timezones($timezone1, 
      var_dump($tz1 > $tz2);
  }
  
 -var_dump($tz1 == $tz2);
+ // Test comparison of uninitialized DateTimeZone objects.
+ class MyDateTimeZone extends DateTimeZone {
+     function __construct() {
+          // parent ctor not called
+     }
+ }
+ $tz1 = new MyDateTimeZone();
+ $tz2 = new MyDateTimeZone();
++try {
++    var_dump($tz1 == $tz2);
++} catch (Error $e) {
++    echo $e->getMessage(), "\n";
++}
  ?>
  --EXPECTF--
  compare +0200 with +0200
@@@ -58,3 -69,6 +73,4 @@@ compare Europe/Amsterdam with Europe/Be
  
  Warning: main(): Trying to compare different kinds of DateTimeZone objects in %s on line %d
  bool(false)
 -
 -Warning: main(): Trying to compare uninitialized DateTimeZone objects in %s on line %d
 -bool(false)
++Trying to compare uninitialized DateTimeZone objects