Merge branch 'PHP-8.2'

* PHP-8.2:
  Fix wrong flags check for compression method in phar_object.c
  Fix missing check for xmlTextWriterEndElement
  Fix substr_replace with slots in repl_ht being UNDEF
This commit is contained in:
George Peter Banyard 2023-01-15 15:43:57 +00:00
commit 5624cbbed1
No known key found for this signature in database
GPG Key ID: 3306078E3194AEBD
4 changed files with 31 additions and 4 deletions

View File

@ -3314,7 +3314,7 @@ PHP_METHOD(Phar, compressFiles)
}
if (!pharobj_cancompress(&phar_obj->archive->manifest)) {
if (flags == PHAR_FILE_COMPRESSED_GZ) {
if (flags == PHAR_ENT_COMPRESSED_GZ) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress all files as Gzip, some are compressed as bzip2 and cannot be decompressed");
} else {

View File

@ -2196,7 +2196,7 @@ PHP_FUNCTION(substr_replace)
if (HT_IS_PACKED(repl_ht)) {
while (repl_idx < repl_ht->nNumUsed) {
tmp_repl = &repl_ht->arPacked[repl_idx];
if (repl_ht != IS_UNDEF) {
if (Z_TYPE_P(tmp_repl) != IS_UNDEF) {
break;
}
repl_idx++;
@ -2204,7 +2204,7 @@ PHP_FUNCTION(substr_replace)
} else {
while (repl_idx < repl_ht->nNumUsed) {
tmp_repl = &repl_ht->arData[repl_idx].val;
if (repl_ht != IS_UNDEF) {
if (Z_TYPE_P(tmp_repl) != IS_UNDEF) {
break;
}
repl_idx++;

View File

@ -0,0 +1,27 @@
--TEST--
substr_replace() function - array with unset
--FILE--
<?php
$replacement = ['A', 'C', 'B'];
unset($replacement[1]);
$newarr = substr_replace(['1 string', '2 string'], $replacement, 0);
print_r($newarr);
$replacement = ['foo', 42 => 'bar', 'baz'];
unset($replacement[42]);
$newarr = substr_replace(['1 string', '2 string'], $replacement, 0);
print_r($newarr);
?>
--EXPECT--
Array
(
[0] => A
[1] => B
)
Array
(
[0] => foo
[1] => baz
)

View File

@ -448,7 +448,7 @@ PHP_FUNCTION(xmlwriter_write_element)
if (retval == -1) {
RETURN_FALSE;
}
xmlTextWriterEndElement(ptr);
retval = xmlTextWriterEndElement(ptr);
if (retval == -1) {
RETURN_FALSE;
}