Skip to content

Commit f9e0482

Browse files
committed
Drop usages of E_RECOVERABLE_ERROR
There were only 2 remaining usages.
1 parent 824a2bf commit f9e0482

8 files changed

+41
-22
lines changed

Zend/tests/temporary_cleaning_014.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ 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;
10-
} catch (Exception $e) {
10+
} catch (\TypeError $e) {
1111
}
1212
?>
1313
DONE

Zend/zend_operators.c

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

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: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -536,21 +536,18 @@ static void php_session_normalize_vars() /* {{{ */
536536
static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */
537537
{
538538
const ps_module *tmp;
539+
int err_type = E_ERROR;
539540

540541
SESSION_CHECK_ACTIVE_STATE;
541542
SESSION_CHECK_OUTPUT_STATE;
542543

543544
tmp = _php_find_ps_module(ZSTR_VAL(new_value));
544545

545-
if (PG(modules_activated) && !tmp) {
546-
int err_type;
547-
548-
if (stage == ZEND_INI_STAGE_RUNTIME) {
549-
err_type = E_WARNING;
550-
} else {
551-
err_type = E_ERROR;
552-
}
546+
if (stage == ZEND_INI_STAGE_RUNTIME) {
547+
err_type = E_WARNING;
548+
}
553549

550+
if (PG(modules_activated) && !tmp) {
554551
/* Do not output error when restoring ini options. */
555552
if (stage != ZEND_INI_STAGE_DEACTIVATE) {
556553
php_error_docref(NULL, err_type, "Session save handler \"%s\" cannot be found", ZSTR_VAL(new_value));
@@ -561,7 +558,7 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */
561558

562559
/* "user" save handler should not be set by user */
563560
if (!PS(set_handler) && tmp == ps_user_ptr) {
564-
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Session save handler \"user\" cannot be set by ini_set() or session_module_name()");
561+
php_error_docref(NULL, err_type, "Session save handler \"user\" cannot be set by ini_set()");
565562
return FAILURE;
566563
}
567564

@@ -1917,6 +1914,10 @@ PHP_FUNCTION(session_module_name)
19171914
}
19181915

19191916
if (name) {
1917+
if (zend_string_equals_literal_ci(name, "user")) {
1918+
zend_argument_value_error(1, "cannot be \"user\"");
1919+
RETURN_THROWS();
1920+
}
19201921
if (!_php_find_ps_module(ZSTR_VAL(name))) {
19211922
php_error_docref(NULL, E_WARNING, "Session handler module \"%s\" cannot be found", ZSTR_VAL(name));
19221923

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: Session save handler "user" cannot be set by ini_set() or session_module_name() in Unknown on line 0
18+
Fatal error: PHP Startup: Session save handler "user" cannot be set 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(): Session save handler module cannot be changed when a session is active in %s on line %d
2428
bool(true)
25-
26-
Recoverable fatal error: session_module_name(): Session save handler "user" cannot be set by ini_set() or session_module_name() in %s on line %d
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(): Session save handler "user" cannot be set 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: Session save handler "user" cannot be set by ini_set() or session_module_name() in Unknown on line 0
24+
Fatal error: PHP Startup: Session save handler "user" cannot be set 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)