Skip to content

Commit ad4533f

Browse files
author
Yasuo Ohgaki
committed
Change E_ERROR and some E_WARNING to E_RECOVERABLE_ERROR.
1 parent 22767a4 commit ad4533f

13 files changed

+70
-41
lines changed

ext/session/mod_user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ PS_CREATE_SID_FUNC(user)
191191
}
192192
zval_ptr_dtor(&retval);
193193
} else {
194-
php_error_docref(NULL, E_ERROR, "No session id returned by function");
194+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "No session id returned by function");
195195
return NULL;
196196
}
197197

198198
if (!id) {
199-
php_error_docref(NULL, E_ERROR, "Session id must be a string");
199+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Session id must be a string");
200200
return NULL;
201201
}
202202

ext/session/mod_user_class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define PS_SANITY_CHECK \
2525
if (PS(default_mod) == NULL) { \
26-
php_error_docref(NULL, E_CORE_ERROR, "Cannot call default session handler"); \
26+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Cannot call default session handler"); \
2727
RETURN_FALSE; \
2828
}
2929

ext/session/session.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
339339
case PS_HASH_FUNC_OTHER:
340340
if (!PS(hash_ops)) {
341341
efree(buf);
342-
php_error_docref(NULL, E_ERROR, "Invalid session hash function");
342+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Invalid session hash function");
343343
return NULL;
344344
}
345345

@@ -351,7 +351,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
351351
#endif /* HAVE_HASH_EXT */
352352
default:
353353
efree(buf);
354-
php_error_docref(NULL, E_ERROR, "Invalid session hash function");
354+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Invalid session hash function");
355355
return NULL;
356356
}
357357
efree(buf);
@@ -480,23 +480,23 @@ static void php_session_initialize(void) /* {{{ */
480480
zend_string *val = NULL;
481481

482482
if (!PS(mod)) {
483-
php_error_docref(NULL, E_ERROR, "No storage module chosen - failed to initialize session");
483+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "No storage module chosen - failed to initialize session");
484484
return;
485485
}
486486

487487
/* Open session handler first */
488488
if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name)) == FAILURE
489489
/* || PS(mod_data) == NULL */ /* FIXME: open must set valid PS(mod_data) with success */
490490
) {
491-
php_error_docref(NULL, E_ERROR, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path));
491+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path));
492492
return;
493493
}
494494

495495
/* If there is no ID, use session module to create one */
496496
if (!PS(id)) {
497497
PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
498498
if (!PS(id)) {
499-
php_error_docref(NULL, E_ERROR, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
499+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
500500
return;
501501
}
502502
if (PS(use_cookies)) {
@@ -600,7 +600,7 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */
600600
int err_type;
601601

602602
if (stage == ZEND_INI_STAGE_RUNTIME) {
603-
err_type = E_WARNING;
603+
err_type = E_RECOVERABLE_ERROR;
604604
} else {
605605
err_type = E_ERROR;
606606
}
@@ -630,7 +630,7 @@ static PHP_INI_MH(OnUpdateSerializer) /* {{{ */
630630
int err_type;
631631

632632
if (stage == ZEND_INI_STAGE_RUNTIME) {
633-
err_type = E_WARNING;
633+
err_type = E_RECOVERABLE_ERROR;
634634
} else {
635635
err_type = E_ERROR;
636636
}
@@ -699,7 +699,7 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */
699699
int err_type;
700700

701701
if (stage == ZEND_INI_STAGE_RUNTIME || stage == ZEND_INI_STAGE_ACTIVATE || stage == ZEND_INI_STAGE_STARTUP) {
702-
err_type = E_WARNING;
702+
err_type = E_RECOVERABLE_ERROR;
703703
} else {
704704
err_type = E_ERROR;
705705
}
@@ -1829,7 +1829,7 @@ static PHP_FUNCTION(session_set_save_handler)
18291829
add_next_index_zval(&PS(mod_user_names).names[i], obj);
18301830
add_next_index_str(&PS(mod_user_names).names[i], zend_string_copy(func_name));
18311831
} else {
1832-
php_error_docref(NULL, E_ERROR, "Session handler's function table is corrupt");
1832+
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Session handler's function table is corrupt");
18331833
RETURN_FALSE;
18341834
}
18351835

ext/session/tests/bug60860.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ echo "ok\n";
1414
--EXPECTF--
1515
Warning: session_start(): user session functions not defined in %s on line 3
1616

17-
Fatal error: session_start(): Failed to initialize storage module: user (path:%s) in %s on line 3
17+
Catchable fatal error: session_start(): Failed to initialize storage module: user (path:%s) in %s on line 3

ext/session/tests/bug66481.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ session.name=
1111
var_dump(session_name("foo"));
1212
var_dump(session_name("bar"));
1313
--EXPECTF--
14-
PHP Warning: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0
14+
PHP Catchable fatal error: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0
1515

16-
Warning: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0
16+
Catchable fatal error: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0
1717
string(9) "PHPSESSID"
1818
string(3) "foo"

ext/session/tests/bug67972.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Bug #67972: SessionHandler Invalid memory read create_sid()
77

88
(new SessionHandler)->create_sid();
99
--EXPECTF--
10-
Fatal error: SessionHandler::create_sid(): Cannot call default session handler in %s on line %d
10+
Catchable fatal error: SessionHandler::create_sid(): Cannot call default session handler in %s on line %d

ext/session/tests/session_module_name_variation3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ Stack trace:
4848
#2 {main}
4949
thrown in %s on line %d
5050

51-
Fatal error: session_start(): Failed to initialize storage module: %s in %s%esession_module_name_variation3.php on line %d
51+
Catchable fatal error: session_start(): Failed to initialize storage module: %s in %s%esession_module_name_variation3.php on line %d

ext/session/tests/session_name_error.phpt

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ session.name=PHPSESSID
88
--FILE--
99
<?php
1010

11+
function error_handler($errno, $errstr, $errfile, $errline)
12+
{
13+
if ($errno & E_NOTICE) {
14+
return ture; // Ignore notices
15+
}
16+
if ($errno & E_RECOVERABLE_ERROR) {
17+
// Handle E_REVOCERABLE_ERROR
18+
echo "\nE_RECOVERABLE_ERROR: {$errstr} in {$errfile} on line {$errline}\n";
19+
return true; // Continue execution
20+
}
21+
return false;
22+
}
23+
24+
set_error_handler('error_handler');
25+
1126
ob_start();
1227

1328
/*
@@ -99,103 +114,103 @@ ob_end_flush();
99114

100115
-- Iteration 1 --
101116

102-
Warning: session_name(): session.name cannot be a numeric or empty '0' in %s on line %d
117+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '0' in %s on line %d
103118
int(0)
104119
string(9) "PHPSESSID"
105120

106121
-- Iteration 2 --
107122

108-
Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
123+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
109124
int(1)
110125
string(9) "PHPSESSID"
111126

112127
-- Iteration 3 --
113128

114-
Warning: session_name(): session.name cannot be a numeric or empty '12345' in %s on line %d
129+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '12345' in %s on line %d
115130
int(12345)
116131
string(9) "PHPSESSID"
117132

118133
-- Iteration 4 --
119134

120-
Warning: session_name(): session.name cannot be a numeric or empty '-2345' in %s on line %d
135+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '-2345' in %s on line %d
121136
int(-2345)
122137
string(9) "PHPSESSID"
123138

124139
-- Iteration 5 --
125140

126-
Warning: session_name(): session.name cannot be a numeric or empty '10.5' in %s on line %d
141+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '10.5' in %s on line %d
127142
float(10.5)
128143
string(9) "PHPSESSID"
129144

130145
-- Iteration 6 --
131146

132-
Warning: session_name(): session.name cannot be a numeric or empty '-10.5' in %s on line %d
147+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '-10.5' in %s on line %d
133148
float(-10.5)
134149
string(9) "PHPSESSID"
135150

136151
-- Iteration 7 --
137152

138-
Warning: session_name(): session.name cannot be a numeric or empty '123456789000' in %s on line %d
153+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '123456789000' in %s on line %d
139154
float(123456789000)
140155
string(9) "PHPSESSID"
141156

142157
-- Iteration 8 --
143158

144-
Warning: session_name(): session.name cannot be a numeric or empty '1.23456789E-9' in %s on line %d
159+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '1.23456789E-9' in %s on line %d
145160
float(1.23456789E-9)
146161
string(9) "PHPSESSID"
147162

148163
-- Iteration 9 --
149164

150-
Warning: session_name(): session.name cannot be a numeric or empty '0.5' in %s on line %d
165+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '0.5' in %s on line %d
151166
float(0.5)
152167
string(9) "PHPSESSID"
153168

154169
-- Iteration 10 --
155170

156-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
171+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
157172
NULL
158173
string(9) "PHPSESSID"
159174

160175
-- Iteration 11 --
161176

162-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
177+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
163178
NULL
164179
string(9) "PHPSESSID"
165180

166181
-- Iteration 12 --
167182

168-
Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
183+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
169184
bool(true)
170185
string(9) "PHPSESSID"
171186

172187
-- Iteration 13 --
173188

174-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
189+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
175190
bool(false)
176191
string(9) "PHPSESSID"
177192

178193
-- Iteration 14 --
179194

180-
Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
195+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
181196
bool(true)
182197
string(9) "PHPSESSID"
183198

184199
-- Iteration 15 --
185200

186-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
201+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
187202
bool(false)
188203
string(9) "PHPSESSID"
189204

190205
-- Iteration 16 --
191206

192-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
207+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
193208
string(0) ""
194209
string(9) "PHPSESSID"
195210

196211
-- Iteration 17 --
197212

198-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
213+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
199214
string(0) ""
200215
string(9) "PHPSESSID"
201216

@@ -218,13 +233,13 @@ string(12) "Hello World!"
218233

219234
-- Iteration 22 --
220235

221-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
236+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
222237
NULL
223238
string(12) "Hello World!"
224239

225240
-- Iteration 23 --
226241

227-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
242+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
228243
NULL
229244
string(12) "Hello World!"
230245

ext/session/tests/session_name_variation1.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ session.name=PHPSESSID
77
<?php include('skipif.inc'); ?>
88
--FILE--
99
<?php
10+
function error_handler($errno, $errstr, $errfile, $errline)
11+
{
12+
if ($errno & E_NOTICE) {
13+
return ture; // Ignore notices
14+
}
15+
if ($errno & E_RECOVERABLE_ERROR) {
16+
// Handle E_REVOCERABLE_ERROR
17+
echo "\nE_RECOVERABLE_ERROR: {$errstr} in {$errfile} on line {$errline}\n";
18+
return true; // Continue execution
19+
}
20+
return false;
21+
}
22+
23+
set_error_handler('error_handler');
1024

1125
ob_start();
1226

@@ -52,7 +66,7 @@ string(1) " "
5266
bool(true)
5367
string(1) " "
5468

55-
Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
69+
E_RECOVERABLE_ERROR: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
5670
string(1) " "
5771
bool(true)
5872
string(1) " "

ext/session/tests/session_save_path_variation4.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ string(0) ""
5656

5757
Warning: session_start(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d
5858

59-
Fatal error: session_start(): Failed to initialize storage module: files (path: ) in %s on line %d
59+
Catchable fatal error: session_start(): Failed to initialize storage module: files (path: ) in %s on line %d
6060

ext/session/tests/session_set_save_handler_class_014.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ session_start();
2727
--EXPECTF--
2828
*** Testing session_set_save_handler() : calling default handler when save_handler=user ***
2929

30-
Fatal error: SessionHandler::open(): Cannot call default session handler in %s on line %d
30+
Catchable fatal error: SessionHandler::open(): Cannot call default session handler in %s on line %d

ext/session/tests/session_set_save_handler_error3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ Stack trace:
4141
#2 {main}
4242
thrown in %s on line %d
4343

44-
Fatal error: session_start(): Failed to initialize storage module: %s in %ssession_set_save_handler_error3.php on line %d
44+
Catchable fatal error: session_start(): Failed to initialize storage module: %s in %ssession_set_save_handler_error3.php on line %d

ext/session/tests/session_set_save_handler_sid_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ session_unset();
7474
--EXPECTF--
7575
*** Testing session_set_save_handler() function: create_sid ***
7676

77-
Fatal error: session_start(): Session id must be a string in %s on line %d
77+
Catchable fatal error: session_start(): Session id must be a string in %s on line %d

0 commit comments

Comments
 (0)