Skip to content

Commit 353b35c

Browse files
committed
Merge branch 'master' into wrong-param-count
2 parents 31929e4 + e1240f2 commit 353b35c

File tree

18 files changed

+139
-80
lines changed

18 files changed

+139
-80
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ PHP NEWS
2020
. Fixed bug GH-20051 (apache2 shutdowns when restart is requested during
2121
preloading). (Arnaud, welcomycozyhom)
2222

23+
- Phar:
24+
. Support reference values in Phar::mungServer(). (nielsdos)
25+
. Invalid values now throw in Phar::mungServer() instead of being silently
26+
ignored. (nielsdos)
27+
2328
- Standard:
2429
. Fixed bug GH-19926 (reset internal pointer earlier while splicing array
2530
while COW violation flag is still set). (alexandre-daubois)

UPGRADING

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ PHP 8.6 UPGRADE NOTES
1919
1. Backward Incompatible Changes
2020
========================================
2121

22+
- Phar:
23+
. Invalid values now throw in Phar::mungServer() instead of being silently
24+
ignored.
25+
2226
========================================
2327
2. New Features
2428
========================================
@@ -44,6 +48,9 @@ PHP 8.6 UPGRADE NOTES
4448
5. Changed Functions
4549
========================================
4650

51+
- Phar:
52+
. Phar::mungServer() now supports reference values.
53+
4754
========================================
4855
6. New Functions
4956
========================================

UPGRADING.INTERNALS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ PHP 8.6 INTERNALS UPGRADE NOTES
2222
added, given the primary flags were running out of bits.
2323
. The zval_is_true() alias of zend_is_true() has been removed. Call
2424
zend_is_true() directly instead.
25+
. The _zval_get_*() compatibility macros for PHP 7.2 have been removed
26+
call the variant without the leading underscore instead.
27+
Affected: _zval_get_long, _zval_get_double, _zval_get_string,
28+
_zval_get_long_func, _zval_get_double_func, _zval_get_string_func
2529
. The WRONG_PARAM_COUNT and ZEND_WRONG_PARAM_COUNT() macros have been
2630
removed. Call zend_wrong_param_count(); followed by RETURN_THROWS();
2731
instead.

Zend/zend_operators.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,6 @@ static zend_always_inline bool try_convert_to_string(zval *op) {
390390
return _try_convert_to_string(op);
391391
}
392392

393-
/* Compatibility macros for 7.2 and below */
394-
#define _zval_get_long(op) zval_get_long(op)
395-
#define _zval_get_double(op) zval_get_double(op)
396-
#define _zval_get_string(op) zval_get_string(op)
397-
#define _zval_get_long_func(op) zval_get_long_func(op)
398-
#define _zval_get_double_func(op) zval_get_double_func(op)
399-
#define _zval_get_string_func(op) zval_get_string_func(op)
400-
401393
#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); }
402394

403395

ext/dom/php_dom.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ static void dom_unset_property(zend_object *object, zend_string *member, void **
488488
zend_std_unset_property(object, member, cache_slot);
489489
}
490490

491+
/* This custom handler is necessary to avoid a recursive construction of the entire subtree. */
491492
static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */
492493
{
493494
dom_object *obj = php_dom_obj_from_obj(object);
@@ -498,6 +499,11 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
498499
dom_prop_handler *entry;
499500
zend_string *object_str;
500501

502+
/* As we have a custom implementation, we must manually check for overrides. */
503+
if (object->ce->__debugInfo) {
504+
return zend_std_get_debug_info(object, is_temp);
505+
}
506+
501507
*is_temp = 1;
502508

503509
std_props = zend_std_get_properties(object);

ext/dom/tests/gh16317.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-16317 (DOM classes do not allow __debugInfo() overrides to work)
3+
--FILE--
4+
<?php
5+
6+
class Demo extends DOMNode {
7+
public function __construct() {}
8+
public function __debugInfo(): array {
9+
return ['x' => 'y'];
10+
}
11+
}
12+
13+
var_dump(new Demo());
14+
15+
?>
16+
--EXPECT--
17+
object(Demo)#1 (1) {
18+
["x"]=>
19+
string(1) "y"
20+
}

ext/gd/gd.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,7 +3605,7 @@ PHP_FUNCTION(imagefilter)
36053605
zval *tmp;
36063606

36073607
typedef void (*image_filter)(INTERNAL_FUNCTION_PARAMETERS);
3608-
zend_long filtertype;
3608+
zend_long filtertype = 0;
36093609
image_filter filters[] =
36103610
{
36113611
php_image_filter_negate ,
@@ -3623,10 +3623,9 @@ PHP_FUNCTION(imagefilter)
36233623
php_image_filter_scatter
36243624
};
36253625

3626-
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > IMAGE_FILTER_MAX_ARGS) {
3627-
zend_wrong_param_count();
3628-
RETURN_THROWS();
3629-
} else if (zend_parse_parameters(2, "Ol", &tmp, gd_image_ce, &filtertype) == FAILURE) {
3626+
/* We need to do some initial ZPP parsing to be able to extract the filter value */
3627+
if (zend_parse_parameters(MIN(2, ZEND_NUM_ARGS()), "Ol*", &tmp, gd_image_ce, &filtertype) == FAILURE) {
3628+
36303629
RETURN_THROWS();
36313630
}
36323631

ext/gd/tests/imagefilter_error1.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ try {
1414
} catch (TypeError $e) {
1515
echo $e->getMessage(), "\n";
1616
}
17+
try {
18+
var_dump(imagefilter(20, 1));
19+
} catch (TypeError $e) {
20+
echo $e->getMessage(), "\n";
21+
}
1722
?>
1823
--EXPECT--
19-
Wrong parameter count for imagefilter()
24+
imagefilter() expects at least 2 arguments, 1 given
25+
imagefilter(): Argument #1 ($image) must be of type GdImage, int given

ext/phar/dirstream.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
349349
{
350350
phar_entry_info entry, *e;
351351
phar_archive_data *phar = NULL;
352-
char *error, *arch, *entry2;
353-
size_t arch_len, entry_len;
352+
char *error, *arch;
353+
size_t arch_len;
354354
php_url *resource = NULL;
355355

356356
/* pre-readonly check, we need to know if this is a data phar */
357-
if (FAILURE == phar_split_fname(url_from, strlen(url_from), &arch, &arch_len, &entry2, &entry_len, 2, 2)) {
357+
if (FAILURE == phar_split_fname(url_from, strlen(url_from), &arch, &arch_len, NULL, NULL, 2, 2)) {
358358
php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\", no phar archive specified", url_from);
359359
return 0;
360360
}
@@ -364,7 +364,6 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
364364
}
365365

366366
efree(arch);
367-
efree(entry2);
368367

369368
if (PHAR_G(readonly) && (!phar || !phar->is_data)) {
370369
php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\", write operations disabled", url_from);
@@ -477,12 +476,12 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
477476
{
478477
phar_entry_info *entry;
479478
phar_archive_data *phar = NULL;
480-
char *error, *arch, *entry2;
481-
size_t arch_len, entry_len;
479+
char *error, *arch;
480+
size_t arch_len;
482481
php_url *resource = NULL;
483482

484483
/* pre-readonly check, we need to know if this is a data phar */
485-
if (FAILURE == phar_split_fname(url, strlen(url), &arch, &arch_len, &entry2, &entry_len, 2, 2)) {
484+
if (FAILURE == phar_split_fname(url, strlen(url), &arch, &arch_len, NULL, NULL, 2, 2)) {
486485
php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\", no phar archive specified, or phar archive does not exist", url);
487486
return 0;
488487
}
@@ -492,7 +491,6 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
492491
}
493492

494493
efree(arch);
495-
efree(entry2);
496494

497495
if (PHAR_G(readonly) && (!phar || !phar->is_data)) {
498496
php_stream_wrapper_log_error(wrapper, options, "phar error: cannot rmdir directory \"%s\", write operations disabled", url);

ext/phar/func_interceptors.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ PHP_FUNCTION(phar_opendir) /* {{{ */
5050
goto skip_phar;
5151
}
5252

53-
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) {
53+
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) {
5454
php_stream_context *context = NULL;
5555
php_stream *stream;
5656
char *name;
5757

58-
efree(entry);
5958
entry = estrndup(filename, filename_len);
6059
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
6160
entry_len = filename_len;
@@ -89,8 +88,8 @@ PHP_FUNCTION(phar_opendir) /* {{{ */
8988

9089
static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool using_include_path)
9190
{
92-
char *arch, *entry;
93-
size_t arch_len, entry_len;
91+
char *arch;
92+
size_t arch_len;
9493
zend_string *fname = zend_get_executed_filename_ex();
9594

9695
/* we are checking for existence of a file within the relative path. Chances are good that this is
@@ -99,13 +98,10 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool
9998
return NULL;
10099
}
101100

102-
if (FAILURE == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) {
101+
if (FAILURE == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) {
103102
return NULL;
104103
}
105104

106-
efree(entry);
107-
entry = NULL;
108-
entry_len = 0;
109105
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
110106
/* retrieving a file defaults to within the current directory, so use this if possible */
111107
phar_archive_data *phar;
@@ -122,8 +118,8 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool
122118
return NULL;
123119
}
124120
} else {
125-
entry_len = ZSTR_LEN(filename);
126-
entry = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &entry_len, 1);
121+
size_t entry_len = ZSTR_LEN(filename);
122+
char *entry = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &entry_len, 1);
127123
if (entry[0] == '/') {
128124
if (!zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
129125
/* this file is not in the phar, use the original path */
@@ -509,9 +505,7 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
509505
phar = PHAR_G(last_phar);
510506
goto splitted;
511507
}
512-
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) {
513-
514-
efree(entry);
508+
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) {
515509
entry = estrndup(filename, filename_length);
516510
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
517511
entry_len = filename_length;
@@ -751,10 +745,9 @@ PHP_FUNCTION(phar_is_file) /* {{{ */
751745
goto skip_phar;
752746
}
753747

754-
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) {
748+
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) {
755749
phar_archive_data *phar;
756750

757-
efree(entry);
758751
entry = filename;
759752
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
760753
entry_len = filename_len;
@@ -817,10 +810,9 @@ PHP_FUNCTION(phar_is_link) /* {{{ */
817810
goto skip_phar;
818811
}
819812

820-
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) {
813+
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) {
821814
phar_archive_data *phar;
822815

823-
efree(entry);
824816
entry = filename;
825817
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
826818
entry_len = filename_len;

0 commit comments

Comments
 (0)