Skip to content

Commit f71484b

Browse files
committed
Drop usages of E_RECOVERABLE_ERROR
There were only 2 remaining usages.
1 parent d2efb7e commit f71484b

8 files changed

+41
-22
lines changed

Zend/tests/temporary_cleaning_014.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Leak in JMP_SET
44
<?php if (!extension_loaded("gmp")) print "skip"; ?>
55
--FILE--
66
<?php
7-
set_error_handler(function() { throw new Exception; });
7+
set_exception_handler(function() { throw new Exception; });
88
try {
99
new GMP ?: null;
1010
} catch (Exception $e) {

Zend/zend_operators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */
25402540
if (zobj->handlers->cast_object(zobj, &tmp, _IS_BOOL) == SUCCESS) {
25412541
return Z_TYPE(tmp) == IS_TRUE;
25422542
}
2543-
zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name));
2543+
zend_type_error("Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name));
25442544
return false;
25452545
}
25462546
/* }}} */

ext/gmp/tests/cast.phpt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ echo $n, "\n";
1010
var_dump((string) $n);
1111
var_dump((int) $n);
1212
var_dump((float) $n);
13-
var_dump((bool) $n);
14-
13+
try {
14+
var_dump((bool) $n);
15+
} catch (\TypeError $e) {
16+
echo $e->getMessage() . \PHP_EOL;
17+
}
1518
?>
16-
--EXPECTF--
19+
--EXPECT--
1720
42
1821
string(2) "42"
1922
int(42)
2023
float(42)
21-
22-
Recoverable fatal error: Object of class GMP could not be converted to bool in %s on line %d
24+
Object of class GMP could not be converted to bool

ext/session/session.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -527,21 +527,18 @@ static void php_session_normalize_vars() /* {{{ */
527527
static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */
528528
{
529529
const ps_module *tmp;
530+
int err_type = E_ERROR;
530531

531532
SESSION_CHECK_ACTIVE_STATE;
532533
SESSION_CHECK_OUTPUT_STATE;
533534

534535
tmp = _php_find_ps_module(ZSTR_VAL(new_value));
535536

536-
if (PG(modules_activated) && !tmp) {
537-
int err_type;
538-
539-
if (stage == ZEND_INI_STAGE_RUNTIME) {
540-
err_type = E_WARNING;
541-
} else {
542-
err_type = E_ERROR;
543-
}
537+
if (stage == ZEND_INI_STAGE_RUNTIME) {
538+
err_type = E_WARNING;
539+
}
544540

541+
if (PG(modules_activated) && !tmp) {
545542
/* Do not output error when restoring ini options. */
546543
if (stage != ZEND_INI_STAGE_DEACTIVATE) {
547544
php_error_docref(NULL, err_type, "Cannot find save handler '%s'", ZSTR_VAL(new_value));
@@ -551,8 +548,8 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */
551548
}
552549

553550
/* "user" save handler should not be set by user */
554-
if (!PS(set_handler) && tmp == ps_user_ptr) {
555-
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Cannot set 'user' save handler by ini_set() or session_module_name()");
551+
if (!PS(set_handler) && tmp == ps_user_ptr) {
552+
php_error_docref(NULL, err_type, "Cannot set 'user' save handler by ini_set()");
556553
return FAILURE;
557554
}
558555

@@ -1896,6 +1893,10 @@ PHP_FUNCTION(session_module_name)
18961893
}
18971894

18981895
if (name) {
1896+
if (zend_string_equals_literal_ci(name, "user")) {
1897+
zend_argument_value_error(1, "cannot be \"user\"");
1898+
RETURN_THROWS();
1899+
}
18991900
if (!_php_find_ps_module(ZSTR_VAL(name))) {
19001901
php_error_docref(NULL, E_WARNING, "Cannot find named PHP session module (%s)", ZSTR_VAL(name));
19011902

ext/session/tests/bug60860.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ echo "ok\n";
1515

1616
?>
1717
--EXPECT--
18-
Recoverable fatal error: PHP Startup: Cannot set 'user' save handler by ini_set() or session_module_name() in Unknown on line 0
18+
Fatal error: PHP Startup: Cannot set 'user' save handler by ini_set() in Unknown on line 0
1919
ok

ext/session/tests/bug73100.phpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ var_dump(session_start());
1414
session_module_name("user");
1515
var_dump(session_destroy());
1616

17-
session_module_name("user");
17+
try {
18+
session_module_name("user");
19+
} catch (\ValueError $e) {
20+
echo $e->getMessage() . \PHP_EOL;
21+
}
1822
?>
1923
===DONE===
2024
--EXPECTF--
2125
bool(true)
2226

2327
Warning: session_module_name(): Cannot change save handler module when session is active in %s on line 4
2428
bool(true)
25-
26-
Recoverable fatal error: session_module_name(): Cannot set 'user' save handler by ini_set() or session_module_name() in %s on line 7
29+
session_module_name(): Argument #1 ($module) cannot be "user"
30+
===DONE===
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Error when setting session.save_handler to user via ini_set
3+
--SKIPIF--
4+
<?php
5+
include('skipif.inc');
6+
?>
7+
--FILE--
8+
<?php
9+
ini_set('session.save_handler', 'user');
10+
?>
11+
--EXPECTF--
12+
Warning: ini_set(): Cannot set 'user' save handler by ini_set() in %s on line %d

ext/session/tests/session_set_save_handler_class_014.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ session_set_save_handler($handler);
2121
session_start();
2222
?>
2323
--EXPECT--
24-
Recoverable fatal error: PHP Startup: Cannot set 'user' save handler by ini_set() or session_module_name() in Unknown on line 0
24+
Fatal error: PHP Startup: Cannot set 'user' save handler by ini_set() in Unknown on line 0
2525
*** Testing session_set_save_handler() : calling default handler when save_handler=user ***

0 commit comments

Comments
 (0)