Skip to content
forked from php/php-src

Commit dbdff8a

Browse files
authored
Merge pull request #22 from php/master
sync
2 parents 86402dc + 96ea06a commit dbdff8a

File tree

397 files changed

+20779
-17364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

397 files changed

+20779
-17364
lines changed

.cirrus.yml

+2
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ arm_task:
385385
-d opcache.jit=function
386386
-P -q -x -j2
387387
-g FAIL,BORK,LEAK,XLEAK
388+
--no-progress
388389
--offline
389390
--show-diff
390391
--show-slow 1000
@@ -397,6 +398,7 @@ arm_task:
397398
-d opcache.jit=tracing
398399
-P -q -x -j2
399400
-g FAIL,BORK,LEAK,XLEAK
401+
--no-progress
400402
--offline
401403
--show-diff
402404
--show-slow 1000

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Collapse generated files within a pull request.
2323
**/*_arginfo.h linguist-generated
2424
/Zend/zend_vm_execute.h linguist-generated
25-
/Zend/zend_vm_opcodes.{h,c} linguist-generated
25+
/Zend/zend_vm_opcodes.[ch] linguist-generated
2626

2727
# The OSS fuzz files are bunary
2828
/ext/date/tests/ossfuzz*.txt binary

CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
/ext/curl @adoy
1515
/ext/date @derickr
1616
/ext/dba @Girgias
17+
/ext/dom @nielsdos
1718
/ext/ffi @dstogov
1819
/ext/gmp @Girgias
1920
/ext/imap @Girgias
2021
/ext/json @bukka
22+
/ext/libxml @nielsdos
2123
/ext/mbstring @alexdowad
2224
/ext/opcache @dstogov @iluuu1994
2325
/ext/openssl @bukka
@@ -26,6 +28,7 @@
2628
/ext/session @Girgias
2729
/ext/sockets @devnexen
2830
/ext/spl @Girgias
31+
/ext/standard @bukka
2932
/main @bukka
3033
/sapi/fpm @bukka
3134
/Zend @iluuu1994

NEWS

+51-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? ????, PHP 8.3.0alpha1
3+
?? ??? ????, PHP 8.3.0alpha2
4+
5+
- Core:
6+
. Fix GH-11388 (Allow "final" modifier when importing a method from a trait).
7+
(nielsdos)
8+
. Fixed bug GH-11406 (segfault with unpacking and magic method closure).
9+
(nielsdos)
10+
11+
- DOM:
12+
. Fix #79700 (wrong use of libxml oldNs leads to performance problem).
13+
(nielsdos)
14+
. Fix #77894 (DOMNode::C14N() very slow on generated DOMDocuments even after
15+
normalisation). (nielsdos)
16+
17+
- Streams:
18+
. Implement GH-8641 (STREAM_NOTIFY_COMPLETED over HTTP never emitted).
19+
(nielsdos, Jakub Zelenka)
20+
. Fix bug GH-10406 (fgets on a redis socket connection fails on PHP 8.3).
21+
(Jakub Zelenka)
22+
23+
08 Jun 2023, PHP 8.3.0alpha1
424

525
- CLI:
626
. Added pdeathsig to builtin server to terminate workers when the master
@@ -35,10 +55,21 @@ PHP NEWS
3555
has inherited it from its parent). (ilutov)
3656
. Fix bug GH-11154 (Negative indices on empty array don't affect next chosen
3757
index). (ColinHDev)
58+
. Fix bug GH-8846 (Implement delayed early binding for classes without
59+
parents). (ilutov)
60+
. Fix bug #79836 (Segfault in concat_function). (nielsdos)
61+
. Fix bug #81705 (type confusion/UAF on set_error_handler with concat
62+
operation). (nielsdos)
63+
. Fix GH-11348 (Closure created from magic method does not accept named
64+
arguments). (nielsdos)
3865

3966
- Date:
4067
. Implement More Appropriate Date/Time Exceptions RFC. (Derick)
4168

69+
- DOM:
70+
. Fix bug GH-8388 (DOMAttr unescapes character reference). (Tim Starling)
71+
. Fix bug GH-11308 (getElementsByTagName() is O(N^2)). (nielsdos)
72+
4273
- Exif:
4374
. Removed unneeded codepaths in exif_process_TIFF_in_JPEG(). (nielsdos)
4475

@@ -115,6 +146,12 @@ PHP NEWS
115146
. Added memfd api usage, on Linux, for zend_shared_alloc_create_lock()
116147
to create an abstract anonymous file for the opcache's lock. (Max Kellermann)
117148

149+
- OpenSSL:
150+
. Added OPENSSL_CMS_OLDMIMETYPE and PKCS7_NOOLDMIMETYPE contants to switch
151+
between mime content types. (Daniel Kesselberg)
152+
. Fixed GH-11054: Reset OpenSSL errors when using a PEM public key.
153+
(Florian Moser)
154+
118155
- PCNTL:
119156
. SA_ONSTACK is now set for pcntl_signal. (Kévin Dunglas)
120157
. Added SIGINFO constant. (David Carlier)
@@ -126,6 +163,11 @@ PHP NEWS
126163
. pg_cancel use thread safe PQcancel api instead. (David Carlier)
127164
. pg_trace new PGSQL_TRACE_SUPPRESS_TIMESTAMPS/PGSQL_TRACE_REGRESS_MODE
128165
contants support. (David Carlier)
166+
. pg_set_error_verbosity adding PGSQL_ERRORS_STATE constant. (David Carlier)
167+
. pg_convert/pg_insert E_WARNING on type errors had been converted to
168+
ValueError/TypeError exceptions. (David Carlier)
169+
. Added pg_set_error_context_visibility to set the context's visibility
170+
within the error messages. (David Carlier)
129171

130172
- Phar:
131173
. Fix memory leak in phar_rename_archive(). (stkeke)
@@ -152,6 +194,10 @@ PHP NEWS
152194
. Fix Segfault when using ReflectionFiber suspended by an internal function.
153195
(danog)
154196

197+
- SAPI:
198+
. Fixed GH-11141 (Could not open input file: should be sent to stderr).
199+
(nielsdos)
200+
155201
- Sockets:
156202
. Added SO_ATTACH_REUSEPORT_CBPF socket option, to give tighter control
157203
over socket binding for a cpu core. (David Carlier)
@@ -184,10 +230,14 @@ PHP NEWS
184230
. Fix GH-11010 (parse_ini_string() now preserves formatting of unquoted
185231
strings starting with numbers when the INI_SCANNER_TYPED flag is
186232
specified). (ilutov)
233+
. Fix GH-10742 (http_response_code emits no error when headers were already
234+
sent). (NattyNarwhal)
187235

188236
- Streams:
189237
. Fixed bug #51056: blocking fread() will block even if data is available.
190238
(Jakub Zelenka)
239+
. Added storing of the original path used to open xport stream.
240+
(Luc Vieillescazes)
191241

192242
- XSLTProcessor:
193243
. Fixed bug #69168 (DomNode::getNodePath() returns invalid path). (nielsdos)

UPGRADING

+22
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ PHP 8.3 UPGRADE NOTES
4141
property to the class directly without traits.
4242
. Assigning a negative index n to an empty array will now make sure that the
4343
next index is n+1 instead of 0.
44+
. Static variable initializers can now contain arbitrary expressions.
45+
RFC: https://wiki.php.net/rfc/arbitrary_static_variable_initializers
46+
47+
- DOM:
48+
. Assignment to DOMAttr::$value and DOMAttr::$nodeValue no longer expands
49+
entities in the new value.
4450

4551
- FFI:
4652
. C functions that have a return type of void now return null instead of
@@ -56,6 +62,8 @@ PHP 8.3 UPGRADE NOTES
5662
RFC: https://wiki.php.net/rfc/readonly_amendments
5763
. Class, interface, trait, and enum constants now support type
5864
declarations. RFC: https://wiki.php.net/rfc/typed_class_constants
65+
. Closures created from magic methods can now accept named arguments.
66+
. The final modifier may now be used when using a method from a trait.
5967

6068
- Posix
6169
. posix_getrlimit() now takes an optional $res parameter to allow fetching a
@@ -64,6 +72,10 @@ PHP 8.3 UPGRADE NOTES
6472
. posix_ttyname() now raises type warnings for integers following the usual ZPP semantics
6573
and value warnings for invalid file descriptor integers.
6674

75+
- Streams
76+
. Streams can now emit the STREAM_NOTIFY_COMPLETED notification. This was previously
77+
not implemented.
78+
6779
========================================
6880
3. Changes in SAPI modules
6981
========================================
@@ -144,6 +156,8 @@ PHP 8.3 UPGRADE NOTES
144156
. pg_fetch_object now raises a ValueError instead of an Exception when the constructor_args
145157
argument is non empty with the class not having constructor.
146158
. pg_insert now raises a ValueError instead of a WARNING when the table specified is invalid.
159+
. pg_insert and pg_convert raises a ValueError or a TypeError instead of a WARNING when the
160+
value/type of a field does not match properly with a PostGreSQL's type.
147161

148162
- Standard:
149163
. E_NOTICEs emitted by unserialize() have been promoted to E_WARNING.
@@ -178,6 +192,9 @@ PHP 8.3 UPGRADE NOTES
178192
. Added posix_fpathconf call to get configuration value from a file descriptor.
179193
. Added posix_eaccess call to check the effective user id's permission for a path.
180194

195+
- PGSQL:
196+
. Added pg_set_error_context_visilibity to set the visibility of the context in error messages.
197+
181198
- Random:
182199
. Added Randomizer::getBytesFromString().
183200
RFC: https://wiki.php.net/rfc/randomizer_additions
@@ -214,12 +231,17 @@ PHP 8.3 UPGRADE NOTES
214231
. MIXED_NUMBERS (Spoofchecker).
215232
. HIDDEN_OVERLAY (Spoofchecker).
216233

234+
- OpenSSL:
235+
. OPENSSL_CMS_OLDMIMETYPE
236+
. PKCS7_NOOLDMIMETYPE
237+
217238
- PCNTL:
218239
. SIGINFO
219240

220241
- PGSQL:
221242
. PGSQL_TRACE_SUPPRESS_TIMESTAMPS.
222243
. PGSQL_TRACE_REGRESS_MODE.
244+
. PGSQL_ERRORS_SQLSTATE.
223245

224246
- Posix:
225247
. POSIX_SC_ARG_MAX.

UPGRADING.INTERNALS

+25
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,31 @@ PHP 8.3 INTERNALS UPGRADE NOTES
116116
- The PHPAPI spl_iterator_apply() function now returns zend_result instead of int.
117117
There are no functional changes.
118118

119+
f. ext/dom
120+
- A new function dom_get_doc_props_read_only() is added to gather the document
121+
properties in a read-only way. This function avoids allocation when there are
122+
no document properties changed yet.
123+
- The node list returned by DOMNode::getElementsByTagName() and
124+
DOMNode::getElementsByTagNameNS() now caches the length and the last requested item.
125+
This means that the length and the last requested item are not recalculated
126+
when the node list is iterated over multiple times.
127+
If you do not use the internal PHP dom APIs to modify the document, you need to
128+
manually invalidate the cache using php_libxml_invalidate_node_list_cache_from_doc().
129+
Furthermore, the following internal APIs were added to handle the cache:
130+
. php_dom_is_cache_tag_stale_from_doc_ptr()
131+
. php_dom_is_cache_tag_stale_from_node()
132+
. php_dom_mark_cache_tag_up_to_date_from_node()
133+
- The function dom_get_elements_by_tag_name_ns_raw() has an additional parameter to indicate
134+
the base node of the node list. This function also no longer accepts -1 as the index argument.
135+
- The function dom_namednode_iter() has additional arguments to avoid recomputing the length of
136+
the strings.
137+
- The functions dom_parent_node_prepend(), dom_parent_node_append(), dom_parent_node_after(), and
138+
dom_parent_node_before() now use an uint32_t argument for the number of nodes instead of int.
139+
140+
g. ext/libxml
141+
- Two new functions: php_libxml_invalidate_node_list_cache_from_doc() and
142+
php_libxml_invalidate_node_list_cache() were added to invalidate the cache of a node list.
143+
119144
========================
120145
4. OpCode changes
121146
========================

Zend/Optimizer/block_pass.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
264264
break;
265265

266266
case ZEND_FREE:
267+
/* Note: Only remove the source if the source is local to this block.
268+
* If it's not local, then the other blocks successors must also eventually either FREE or consume the temporary,
269+
* hence removing the temporary is not safe in the general case, especially when other consumers are not FREE.
270+
* A FREE may not be removed without also removing the source's result, because otherwise that would cause a memory leak. */
267271
if (opline->op1_type == IS_TMP_VAR) {
268272
src = VAR_SOURCE(opline->op1);
269273
if (src) {
@@ -272,6 +276,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
272276
case ZEND_BOOL_NOT:
273277
/* T = BOOL(X), FREE(T) => T = BOOL(X) */
274278
/* The remaining BOOL is removed by a separate optimization */
279+
/* The source is a bool, no source removals take place, so this may be done non-locally. */
275280
VAR_SOURCE(opline->op1) = NULL;
276281
MAKE_NOP(opline);
277282
++(*opt_count);
@@ -290,6 +295,9 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
290295
case ZEND_PRE_DEC_OBJ:
291296
case ZEND_PRE_INC_STATIC_PROP:
292297
case ZEND_PRE_DEC_STATIC_PROP:
298+
if (src < op_array->opcodes + block->start) {
299+
break;
300+
}
293301
src->result_type = IS_UNUSED;
294302
VAR_SOURCE(opline->op1) = NULL;
295303
MAKE_NOP(opline);
@@ -302,7 +310,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
302310
} else if (opline->op1_type == IS_VAR) {
303311
src = VAR_SOURCE(opline->op1);
304312
/* V = OP, FREE(V) => OP. NOP */
305-
if (src &&
313+
if (src >= op_array->opcodes + block->start &&
306314
src->opcode != ZEND_FETCH_R &&
307315
src->opcode != ZEND_FETCH_STATIC_PROP_R &&
308316
src->opcode != ZEND_FETCH_DIM_R &&
@@ -1002,6 +1010,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op
10021010
case ZEND_COALESCE:
10031011
case ZEND_ASSERT_CHECK:
10041012
case ZEND_JMP_NULL:
1013+
case ZEND_BIND_INIT_STATIC_OR_JMP:
10051014
ZEND_SET_OP_JMP_ADDR(opline, opline->op2, new_opcodes + blocks[b->successors[0]].start);
10061015
break;
10071016
case ZEND_CATCH:

Zend/Optimizer/dce.c

+4-9
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ static inline bool may_have_side_effects(
145145
case ZEND_COALESCE:
146146
case ZEND_ASSERT_CHECK:
147147
case ZEND_JMP_NULL:
148+
case ZEND_BIND_INIT_STATIC_OR_JMP:
148149
/* For our purposes a jumps and branches are side effects. */
149150
return 1;
150151
case ZEND_BEGIN_SILENCE:
@@ -245,15 +246,9 @@ static inline bool may_have_side_effects(
245246
if ((opline->extended_value & (ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT))) {
246247
return 1;
247248
}
248-
249-
if ((opline->extended_value & ZEND_BIND_REF) != 0) {
250-
zval *value =
251-
(zval*)((char*)op_array->static_variables->arData +
252-
(opline->extended_value & ~ZEND_BIND_REF));
253-
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
254-
/* AST may contain undefined constants */
255-
return 1;
256-
}
249+
/* Modifies static variables which are observable through reflection */
250+
if ((opline->extended_value & ZEND_BIND_REF) && opline->op2_type != IS_UNUSED) {
251+
return 1;
257252
}
258253
}
259254
return 0;

Zend/Optimizer/dfa_pass.c

+1
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ static void zend_ssa_replace_control_link(zend_op_array *op_array, zend_ssa *ssa
652652
case ZEND_COALESCE:
653653
case ZEND_ASSERT_CHECK:
654654
case ZEND_JMP_NULL:
655+
case ZEND_BIND_INIT_STATIC_OR_JMP:
655656
if (ZEND_OP2_JMP_ADDR(opline) == op_array->opcodes + old->start) {
656657
ZEND_SET_OP_JMP_ADDR(opline, opline->op2, op_array->opcodes + dst->start);
657658
}

Zend/Optimizer/pass1.c

+1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
354354
case ZEND_ASSERT_CHECK:
355355
case ZEND_JMP_NULL:
356356
case ZEND_VERIFY_NEVER_TYPE:
357+
case ZEND_BIND_INIT_STATIC_OR_JMP:
357358
collect_constants = 0;
358359
break;
359360
}

Zend/Optimizer/sccp.c

+2
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static bool can_replace_op1(
249249
case ZEND_ROPE_ADD:
250250
case ZEND_ROPE_END:
251251
case ZEND_BIND_STATIC:
252+
case ZEND_BIND_INIT_STATIC_OR_JMP:
252253
case ZEND_BIND_GLOBAL:
253254
case ZEND_MAKE_REF:
254255
case ZEND_UNSET_CV:
@@ -1773,6 +1774,7 @@ static void sccp_mark_feasible_successors(
17731774
case ZEND_CATCH:
17741775
case ZEND_FE_FETCH_R:
17751776
case ZEND_FE_FETCH_RW:
1777+
case ZEND_BIND_INIT_STATIC_OR_JMP:
17761778
scdf_mark_edge_feasible(scdf, block_num, block->successors[0]);
17771779
scdf_mark_edge_feasible(scdf, block_num, block->successors[1]);
17781780
return;

Zend/Optimizer/zend_cfg.c

+2
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ ZEND_API void zend_build_cfg(zend_arena **arena, const zend_op_array *op_array,
369369
case ZEND_COALESCE:
370370
case ZEND_ASSERT_CHECK:
371371
case ZEND_JMP_NULL:
372+
case ZEND_BIND_INIT_STATIC_OR_JMP:
372373
BB_START(OP_JMP_ADDR(opline, opline->op2) - op_array->opcodes);
373374
BB_START(i + 1);
374375
break;
@@ -522,6 +523,7 @@ ZEND_API void zend_build_cfg(zend_arena **arena, const zend_op_array *op_array,
522523
case ZEND_COALESCE:
523524
case ZEND_ASSERT_CHECK:
524525
case ZEND_JMP_NULL:
526+
case ZEND_BIND_INIT_STATIC_OR_JMP:
525527
block->successors_count = 2;
526528
block->successors[0] = block_map[OP_JMP_ADDR(opline, opline->op2) - op_array->opcodes];
527529
block->successors[1] = j + 1;

Zend/Optimizer/zend_dfg.c

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static zend_always_inline void _zend_dfg_add_use_def_op(const zend_op_array *op_
150150
case ZEND_POST_DEC:
151151
case ZEND_BIND_GLOBAL:
152152
case ZEND_BIND_STATIC:
153+
case ZEND_BIND_INIT_STATIC_OR_JMP:
153154
case ZEND_SEND_VAR_NO_REF:
154155
case ZEND_SEND_VAR_NO_REF_EX:
155156
case ZEND_SEND_VAR_EX:

0 commit comments

Comments
 (0)