Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ PHP NEWS
been deprecated, as it no longer has any effect since PHP 8.0. (Girgias)
. Terminating case statements with a semicolon instead of a colon has
been deprecated. (theodorejb)
. The backtick operator as an alias for shell_exec() has been deprecated.
(timwolla)
. Returning null from __debugInfo() has been deprecated. (DanielEScherzer)

- Date:
. The DATE_RFC7231 and DateTimeInterface::RFC7231 constants have been
deprecated. (jorgsowa)

- DOM:
. Fixed bug GH-18877 (\Dom\HTMLDocument querySelectorAll selecting only the
Expand Down
11 changes: 11 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ PHP 8.5 UPGRADE NOTES
. Terminating case statements with a semicolon instead of a colon has
been deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_semicolon_after_case_in_switch_statement
. The backtick operator as an alias for shell_exec() has been deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_backticks_as_an_alias_for_shell_exec
. Returning null from __debugInfo() has been deprecated.
Return an empty array instead.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_debuginfo_returning_null

- Date:
. The DATE_RFC7231 and DateTimeInterface::RFC7231 constants have been
deprecated. This is because the associated timezone is ignored and always
uses GMT.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_date_rfc7231_and_datetimeinterfacerfc7231

- FileInfo:
. The finfo_close() function has been deprecated.
Expand Down
8 changes: 8 additions & 0 deletions Zend/Optimizer/block_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
}
break;

case ZEND_EXT_STMT:
if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
/* Variable will be deleted later by FREE, so we can't optimize it */
Tsource[VAR_NUM(opline->op1.var)] = NULL;
break;
}
break;

case ZEND_CASE:
case ZEND_CASE_STRICT:
case ZEND_COPY_TMP:
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug40236.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (extension_loaded("readline")) die("skip Test doesn't support readline");
<?php
$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
$cmd = "$php -n -d memory_limit=4M -a \"".__DIR__."\"/bug40236.inc";
echo `$cmd`;
echo shell_exec($cmd);
?>
--EXPECT--
Interactive shell (-a) requires the readline extension.
2 changes: 1 addition & 1 deletion Zend/tests/bug55509.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (PHP_OS == 'Linux') {
}
}
elseif (PHP_OS == 'FreeBSD') {
$lines = explode("\n",`sysctl -a`);
$lines = explode("\n", shell_exec("sysctl -a"));
$infos = array();
foreach ($lines as $line) {
if (!$line){
Expand Down
9 changes: 8 additions & 1 deletion Zend/tests/bug64677.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ function show_outputa($prepend, $output) {
show_outputa('Files: ', `cd .`); // this works as expected

?>
--EXPECT--
--EXPECTF--
Deprecated: The backtick (`) operator is deprecated, use shell_exec() instead in %s on line %d

Deprecated: The backtick (`) operator is deprecated, use shell_exec() instead in %s on line %d

Deprecated: The backtick (`) operator is deprecated, use shell_exec() instead in %s on line %d

Deprecated: The backtick (`) operator is deprecated, use shell_exec() instead in %s on line %d
Okey
2 changes: 2 additions & 0 deletions Zend/tests/debug_info/debug_info.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ object(Foo)#%d (3) {
["c":"Foo":private]=>
int(3)
}

Deprecated: Returning null from Bar::__debugInfo() is deprecated, return an empty array instead in %s on line %d
object(Bar)#%d (0) {
}
31 changes: 31 additions & 0 deletions Zend/tests/debug_info/recursion_return_null.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
Testing __debugInfo() magic method
--FILE--
<?php

set_error_handler(
static function () {
echo "in handler\n";
$f = new Foo();
var_dump($f);
}
);

class Foo {
public function __debugInfo() {
return null;
}
}

$f = new Foo;
var_dump($f);

?>
--EXPECTF--
in handler

Deprecated: Returning null from Foo::__debugInfo() is deprecated, return an empty array instead in %s on line %d
object(Foo)#3 (0) {
}
object(Foo)#2 (0) {
}
10 changes: 5 additions & 5 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -3770,7 +3770,7 @@ static zend_always_inline zend_class_entry *get_scope(zend_execute_data *frame)

static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error, bool suppress_deprecation) /* {{{ */
{
bool ret = 0;
bool ret = false;
zend_class_entry *ce;
size_t name_len = ZSTR_LEN(name);
zend_string *lcname;
Expand All @@ -3795,7 +3795,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
if (!fcc->object) {
fcc->object = zend_get_this_object(frame);
}
ret = 1;
ret = true;
}
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_PARENT))) {
if (!scope) {
Expand All @@ -3815,7 +3815,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
fcc->object = zend_get_this_object(frame);
}
*strict_class = 1;
ret = 1;
ret = true;
}
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_STATIC))) {
zend_class_entry *called_scope = zend_get_called_scope(frame);
Expand All @@ -3832,7 +3832,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
fcc->object = zend_get_this_object(frame);
}
*strict_class = 1;
ret = 1;
ret = true;
}
} else if ((ce = zend_lookup_class(name)) != NULL) {
zend_class_entry *scope = get_scope(frame);
Expand All @@ -3852,7 +3852,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
fcc->called_scope = fcc->object ? fcc->object->ce : ce;
}
*strict_class = 1;
ret = 1;
ret = true;
} else {
if (error) zend_spprintf(error, 0, "class \"%.*s\" not found", (int)name_len, ZSTR_VAL(name));
}
Expand Down
20 changes: 14 additions & 6 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,8 @@ static void zend_do_free(znode *op1) /* {{{ */
} else {
while (opline >= CG(active_op_array)->opcodes) {
if ((opline->opcode == ZEND_FETCH_LIST_R ||
opline->opcode == ZEND_FETCH_LIST_W) &&
opline->opcode == ZEND_FETCH_LIST_W ||
opline->opcode == ZEND_EXT_STMT) &&
opline->op1_type == IS_VAR &&
opline->op1.var == op1->u.op.var) {
zend_emit_op(NULL, ZEND_FREE, op1, NULL);
Expand Down Expand Up @@ -1920,7 +1921,7 @@ static void zend_add_to_list(void *result, void *item) /* {{{ */
}
/* }}} */

static void zend_do_extended_stmt(void) /* {{{ */
static void zend_do_extended_stmt(znode* result) /* {{{ */
{
zend_op *opline;

Expand All @@ -1931,6 +1932,9 @@ static void zend_do_extended_stmt(void) /* {{{ */
opline = get_next_op();

opline->opcode = ZEND_EXT_STMT;
if (result) {
SET_NODE(opline->op1, result);
}
}
/* }}} */

Expand Down Expand Up @@ -6050,7 +6054,7 @@ static void zend_compile_for(zend_ast *ast) /* {{{ */

zend_update_jump_target_to_next(opnum_jmp);
zend_compile_for_expr_list(&result, cond_ast);
zend_do_extended_stmt();
zend_do_extended_stmt(NULL);

zend_emit_cond_jump(ZEND_JMPNZ, &result, opnum_start);

Expand Down Expand Up @@ -6171,7 +6175,7 @@ static void zend_compile_if(zend_ast *ast) /* {{{ */

if (i > 0) {
CG(zend_lineno) = cond_ast->lineno;
zend_do_extended_stmt();
zend_do_extended_stmt(NULL);
}

zend_compile_expr(&cond_node, cond_ast);
Expand Down Expand Up @@ -6505,6 +6509,8 @@ static void zend_compile_pipe(znode *result, zend_ast *ast)
}

zend_compile_expr(result, fcall_ast);
CG(zend_lineno) = fcall_ast->lineno;
zend_do_extended_stmt(result);
}

static void zend_compile_match(znode *result, zend_ast *ast)
Expand Down Expand Up @@ -8537,7 +8543,7 @@ static zend_op_array *zend_compile_func_decl_ex(
/* put the implicit return on the really last line */
CG(zend_lineno) = decl->end_lineno;

zend_do_extended_stmt();
zend_do_extended_stmt(NULL);
zend_emit_final_return(0);

pass_two(CG(active_op_array));
Expand Down Expand Up @@ -10841,6 +10847,8 @@ static void zend_compile_shell_exec(znode *result, zend_ast *ast) /* {{{ */
zval fn_name;
zend_ast *name_ast, *args_ast, *call_ast;

zend_error(E_DEPRECATED, "The backtick (`) operator is deprecated, use shell_exec() instead");

ZVAL_STRING(&fn_name, "shell_exec");
name_ast = zend_ast_create_zval(&fn_name);
args_ast = zend_ast_create_list(1, ZEND_AST_ARG_LIST, expr_ast);
Expand Down Expand Up @@ -11607,7 +11615,7 @@ static void zend_compile_stmt(zend_ast *ast) /* {{{ */
CG(zend_lineno) = ast->lineno;

if ((CG(compiler_options) & ZEND_COMPILE_EXTENDED_STMT) && !zend_is_unticked_stmt(ast)) {
zend_do_extended_stmt();
zend_do_extended_stmt(NULL);
}

switch (ast->kind) {
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) /
return Z_ARRVAL(retval);
}
} else if (Z_TYPE(retval) == IS_NULL) {
zend_error(E_DEPRECATED, "Returning null from %s::__debugInfo() is deprecated, return an empty array instead",
ZSTR_VAL(ce->name));
*is_temp = 1;
ht = zend_new_array(0);
return ht;
Expand Down
3 changes: 2 additions & 1 deletion Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,8 @@ static bool keeps_op1_alive(zend_op *opline) {
|| opline->opcode == ZEND_MATCH_ERROR
|| opline->opcode == ZEND_FETCH_LIST_R
|| opline->opcode == ZEND_FETCH_LIST_W
|| opline->opcode == ZEND_COPY_TMP) {
|| opline->opcode == ZEND_COPY_TMP
|| opline->opcode == ZEND_EXT_STMT) {
return 1;
}
ZEND_ASSERT(opline->opcode != ZEND_FE_FETCH_R
Expand Down
3 changes: 2 additions & 1 deletion ext/date/php_date.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* @var string
* @cvalue DATE_FORMAT_RFC7231
*/
#[\Deprecated(since: '8.5', message: "as this format ignores the associated timezone and always uses GMT")]
const DATE_RFC7231 = "D, d M Y H:i:s \\G\\M\\T";

/**
Expand Down Expand Up @@ -287,7 +288,6 @@ function date_sun_info(int $timestamp, float $latitude, float $longitude): array

interface DateTimeInterface
{

public const string ATOM = DATE_ATOM;

public const string COOKIE = DATE_COOKIE;
Expand All @@ -304,6 +304,7 @@ interface DateTimeInterface

public const string RFC1123 = DATE_RFC1123;

#[\Deprecated(since: '8.5', message: "as this format ignores the associated timezone and always uses GMT")]
public const string RFC7231 = DATE_RFC7231;

public const string RFC2822 = DATE_RFC2822;
Expand Down
21 changes: 18 additions & 3 deletions ext/date/php_date_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion ext/date/tests/DateTimeImmutable_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var_dump(
);

?>
--EXPECT--
--EXPECTF--
Deprecated: Constant DATE_RFC7231 is deprecated since 8.5, as this format ignores the associated timezone and always uses GMT in %s on line %d

Deprecated: Constant DateTimeInterface::RFC7231 is deprecated since 8.5, as this format ignores the associated timezone and always uses GMT in %s on line %d
bool(true)
bool(true)
bool(true)
Expand Down
5 changes: 4 additions & 1 deletion ext/date/tests/DateTimeInterface_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var_dump(
);

?>
--EXPECT--
--EXPECTF--
Deprecated: Constant DATE_RFC7231 is deprecated since 8.5, as this format ignores the associated timezone and always uses GMT in %s on line %d

Deprecated: Constant DateTimeInterface::RFC7231 is deprecated since 8.5, as this format ignores the associated timezone and always uses GMT in %s on line %d
bool(true)
bool(true)
bool(true)
Expand Down
5 changes: 4 additions & 1 deletion ext/date/tests/DateTime_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var_dump(
);

?>
--EXPECT--
--EXPECTF--
Deprecated: Constant DATE_RFC7231 is deprecated since 8.5, as this format ignores the associated timezone and always uses GMT in %s on line %d

Deprecated: Constant DateTimeInterface::RFC7231 is deprecated since 8.5, as this format ignores the associated timezone and always uses GMT in %s on line %d
bool(true)
bool(true)
bool(true)
Expand Down
4 changes: 3 additions & 1 deletion ext/date/tests/DateTime_format_basic2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var_dump($date->format(DateTime::RSS));
var_dump($date->format(DateTime::W3C));

?>
--EXPECT--
--EXPECTF--
*** Testing date_format() : basic functionality - formatting constants ***
string(25) "2005-07-14T22:30:41+01:00"
string(34) "Thursday, 14-Jul-2005 22:30:41 BST"
Expand All @@ -34,6 +34,8 @@ string(29) "Thu, 14 Jul 05 22:30:41 +0100"
string(32) "Thursday, 14-Jul-05 22:30:41 BST"
string(29) "Thu, 14 Jul 05 22:30:41 +0100"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"

Deprecated: Constant DateTimeInterface::RFC7231 is deprecated since 8.5, as this format ignores the associated timezone and always uses GMT in %s on line %d
string(29) "Thu, 14 Jul 2005 22:30:41 GMT"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(25) "2005-07-14T22:30:41+01:00"
Expand Down
Loading