Skip to content

Commit 771e5cc

Browse files
committed
Replace zend_ce_error with NULL and replace more E_ERROR with thrown Error
1 parent e3c681a commit 771e5cc

30 files changed

+101
-65
lines changed

ext/date/php_date.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "ext/standard/php_math.h"
2929
#include "php_date.h"
3030
#include "zend_interfaces.h"
31-
#include "zend_exceptions.h"
3231
#include "lib/timelib.h"
3332
#include <time.h>
3433

@@ -2786,7 +2785,7 @@ PHP_METHOD(DateTime, __set_state)
27862785
php_date_instantiate(date_ce_date, return_value);
27872786
dateobj = Z_PHPDATE_P(return_value);
27882787
if (!php_date_initialize_from_hash(&dateobj, myht)) {
2789-
php_error(E_ERROR, "Invalid serialization data for DateTime object");
2788+
zend_throw_error(NULL, "Invalid serialization data for DateTime object");
27902789
}
27912790
}
27922791
/* }}} */
@@ -2808,7 +2807,7 @@ PHP_METHOD(DateTimeImmutable, __set_state)
28082807
php_date_instantiate(date_ce_immutable, return_value);
28092808
dateobj = Z_PHPDATE_P(return_value);
28102809
if (!php_date_initialize_from_hash(&dateobj, myht)) {
2811-
php_error(E_ERROR, "Invalid serialization data for DateTimeImmutable object");
2810+
zend_throw_error(NULL, "Invalid serialization data for DateTimeImmutable object");
28122811
}
28132812
}
28142813
/* }}} */
@@ -2826,7 +2825,7 @@ PHP_METHOD(DateTime, __wakeup)
28262825
myht = Z_OBJPROP_P(object);
28272826

28282827
if (!php_date_initialize_from_hash(&dateobj, myht)) {
2829-
php_error(E_ERROR, "Invalid serialization data for DateTime object");
2828+
zend_throw_error(NULL, "Invalid serialization data for DateTime object");
28302829
}
28312830
}
28322831
/* }}} */
@@ -3706,7 +3705,7 @@ PHP_METHOD(DateTimeZone, __set_state)
37063705
php_date_instantiate(date_ce_timezone, return_value);
37073706
tzobj = Z_PHPTIMEZONE_P(return_value);
37083707
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) {
3709-
zend_throw_error(zend_ce_error, "Timezone initialization failed");
3708+
zend_throw_error(NULL, "Timezone initialization failed");
37103709
zval_dtor(return_value);
37113710
RETURN_FALSE;
37123711
}
@@ -3726,7 +3725,7 @@ PHP_METHOD(DateTimeZone, __wakeup)
37263725
myht = Z_OBJPROP_P(object);
37273726

37283727
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) {
3729-
zend_throw_error(zend_ce_error, "Timezone initialization failed");
3728+
zend_throw_error(NULL, "Timezone initialization failed");
37303729
RETURN_FALSE;
37313730
}
37323731
}
@@ -5007,7 +5006,7 @@ PHP_METHOD(DatePeriod, __set_state)
50075006
object_init_ex(return_value, date_ce_period);
50085007
period_obj = Z_PHPPERIOD_P(return_value);
50095008
if (!php_date_period_initialize_from_hash(period_obj, myht)) {
5010-
php_error(E_ERROR, "Invalid serialization data for DatePeriod object");
5009+
zend_throw_error(NULL, "Invalid serialization data for DatePeriod object");
50115010
}
50125011
}
50135012
/* }}} */
@@ -5025,7 +5024,7 @@ PHP_METHOD(DatePeriod, __wakeup)
50255024
myht = Z_OBJPROP_P(object);
50265025

50275026
if (!php_date_period_initialize_from_hash(period_obj, myht)) {
5028-
php_error(E_ERROR, "Invalid serialization data for DatePeriod object");
5027+
zend_throw_error(NULL, "Invalid serialization data for DatePeriod object");
50295028
}
50305029
}
50315030
/* }}} */
@@ -5035,7 +5034,7 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi
50355034
{
50365035
zval *zv;
50375036
if (type != BP_VAR_IS && type != BP_VAR_R) {
5038-
zend_throw_error(zend_ce_error, "Retrieval of DatePeriod properties for modification is unsupported");
5037+
zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported");
50395038
return &EG(uninitialized_zval);
50405039
}
50415040

@@ -5054,7 +5053,7 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi
50545053
/* {{{ date_period_write_property */
50555054
static void date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot)
50565055
{
5057-
zend_throw_error(zend_ce_error, "Writing to DatePeriod properties is unsupported");
5056+
zend_throw_error(NULL, "Writing to DatePeriod properties is unsupported");
50585057
}
50595058
/* }}} */
50605059

ext/date/tests/bug53437_var1.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ var_dump($dp);
1010
?>
1111
==DONE==
1212
--EXPECTF--
13-
Fatal error: Invalid serialization data for DatePeriod object in %sbug53437_var1.php on line %d
13+
Fatal error: Uncaught Error: Invalid serialization data for DatePeriod object in %sbug53437_var1.php:%d
14+
Stack trace:
15+
#0 [internal function]: DatePeriod->__wakeup()
16+
#1 %sbug53437_var1.php(%d): unserialize('O:10:"DatePerio...')
17+
#2 {main}
18+
thrown in %sbug53437_var1.php on line %d

ext/date/tests/bug55397.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ date_default_timezone_set('Europe/Prague');
77
var_dump(unserialize('O:8:"DateTime":0:{}') == new DateTime);
88
?>
99
--EXPECTF--
10-
Fatal error: Invalid serialization data for DateTime object in %sbug55397.php on line %d
10+
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug55397.php:%d
11+
Stack trace:
12+
#0 [internal function]: DateTime->__wakeup()
13+
#1 %sbug55397.php(%d): unserialize('O:8:"DateTime":...')
14+
#2 {main}
15+
thrown in %sbug55397.php on line %d

ext/date/tests/bug62852.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ try {
1111
} catch ( Exception $e ) {}
1212

1313
--EXPECTF--
14-
Fatal error: Invalid serialization data for DateTime object in %sbug62852.php on line %d
14+
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug62852.php:%d
15+
Stack trace:
16+
#0 [internal function]: DateTime->__wakeup()
17+
#1 %sbug62852.php(%d): unserialize('O:8:"DateTime":...')
18+
#2 {main}
19+
thrown in %sbug62852.php on line %d

ext/date/tests/bug62852_var2.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ try {
2222
var_dump( $foo );
2323

2424
--EXPECTF--
25-
Fatal error: Invalid serialization data for DateTime object in %sbug62852_var2.php on line %d
25+
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug62852_var2.php:%d
26+
Stack trace:
27+
#0 %sbug62852_var2.php(%d): DateTime->__wakeup()
28+
#1 [internal function]: Foo->__wakeup()
29+
#2 %sbug62852_var2.php(%d): unserialize('O:3:"Foo":3:{s:...')
30+
#3 {main}
31+
thrown in %sbug62852_var2.php on line %d

ext/date/tests/bug62852_var3.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ try {
2222
var_dump( $foo );
2323

2424
--EXPECTF--
25-
Fatal error: Invalid serialization data for DateTime object in %sbug62852_var3.php on line %d
25+
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug62852_var3.php:%d
26+
Stack trace:
27+
#0 %sbug62852_var3.php(%d): DateTime->__wakeup()
28+
#1 [internal function]: Foo->__wakeup()
29+
#2 %sbug62852_var3.php(%d): unserialize('O:3:"Foo":3:{s:...')
30+
#3 {main}
31+
thrown in %sbug62852_var3.php on line %d

ext/date/tests/bug66721.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ $y = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-02-15 02:00:51";s:13:"timezone_typ
88
var_dump(unserialize($y));
99
?>
1010
--EXPECTF--
11-
Fatal error: Invalid serialization data for DateTime object in %s on line %d
11+
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug66721.php:%d
12+
Stack trace:
13+
#0 [internal function]: DateTime->__wakeup()
14+
#1 %sbug66721.php(%d): unserialize('O:8:"DateTime":...')
15+
#2 {main}
16+
thrown in %sbug66721.php on line %d

ext/date/tests/bug68942_2.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ $data = unserialize('a:2:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"2000-01-01 00:0
66
var_dump($data);
77
?>
88
--EXPECTF--
9-
Fatal error: Invalid serialization data for DateTime object in %s%ebug68942_2.php on line %d
9+
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug68942_2.php:%d
10+
Stack trace:
11+
#0 [internal function]: DateTime->__wakeup()
12+
#1 %sbug68942_2.php(%d): unserialize('a:2:{i:0;O:8:"D...')
13+
#2 {main}
14+
thrown in %sbug68942_2.php on line %d

ext/dom/document.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
18561856
vptr = xmlSchemaNewValidCtxt(sptr);
18571857
if (!vptr) {
18581858
xmlSchemaFree(sptr);
1859-
php_error(E_ERROR, "Invalid Schema Validation Context");
1859+
zend_throw_error(NULL, "Invalid Schema Validation Context");
18601860
RETURN_FALSE;
18611861
}
18621862

@@ -1956,7 +1956,7 @@ static void _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int typ
19561956
vptr = xmlRelaxNGNewValidCtxt(sptr);
19571957
if (!vptr) {
19581958
xmlRelaxNGFree(sptr);
1959-
php_error(E_ERROR, "Invalid RelaxNG Validation Context");
1959+
zend_throw_error(NULL, "Invalid RelaxNG Validation Context");
19601960
RETURN_FALSE;
19611961
}
19621962

@@ -2248,7 +2248,7 @@ PHP_METHOD(domdocument, registerNodeClass)
22482248
RETURN_TRUE;
22492249
}
22502250

2251-
zend_throw_error(zend_ce_error, "Class %s is not derived from %s.", ZSTR_VAL(ce->name), ZSTR_VAL(basece->name));
2251+
zend_throw_error(NULL, "Class %s is not derived from %s.", ZSTR_VAL(ce->name), ZSTR_VAL(basece->name));
22522252
RETURN_FALSE;
22532253
}
22542254
/* }}} */

ext/dom/php_dom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,15 @@ PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj)
285285
/* {{{ dom_read_na */
286286
static int dom_read_na(dom_object *obj, zval *retval)
287287
{
288-
zend_throw_error(zend_ce_error, "Cannot read property");
288+
zend_throw_error(NULL, "Cannot read property");
289289
return FAILURE;
290290
}
291291
/* }}} */
292292

293293
/* {{{ dom_write_na */
294294
static int dom_write_na(dom_object *obj, zval *newval)
295295
{
296-
zend_throw_error(zend_ce_error, "Cannot write property");
296+
zend_throw_error(NULL, "Cannot write property");
297297
return FAILURE;
298298
}
299299
/* }}} */

0 commit comments

Comments
 (0)