Skip to content

Commit 2a022f1

Browse files
authored
Merge branch 'php:master' into master
2 parents 7256b13 + 7ce5e0a commit 2a022f1

File tree

155 files changed

+2371
-1031
lines changed

Some content is hidden

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

155 files changed

+2371
-1031
lines changed

.gitattributes

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
/UPGRADING merge=NEWS
1414
/UPGRADING.INTERNALS merge=NEWS
1515

16-
# Enable commit diffs for binary PHP test files. Some PHP test files include
17-
# special characters, such as ASCII control characters. Git recognizes these as
18-
# binary and wouldn't generate diffs.
19-
*.phpt diff
16+
# Configure proper diff drivers to improve the context lines in the output
17+
# of git diff and to improve token splitting for --word-diff.
18+
*.phpt diff=php
19+
*.php diff=php
20+
*.[ch] diff=cpp

.github/actions/apt-x64/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ runs:
5959
libpng-dev \
6060
libfreetype6-dev
6161
mkdir /opt/oracle
62-
wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
63-
unzip instantclient-basiclite-linuxx64.zip
64-
wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-sdk-linuxx64.zip
65-
unzip instantclient-sdk-linuxx64.zip
62+
wget -nv https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
63+
unzip instantclient-basiclite-linuxx64.zip && rm instantclient-basiclite-linuxx64.zip
64+
wget -nv https://download.oracle.com/otn_software/linux/instantclient/instantclient-sdk-linuxx64.zip
65+
unzip instantclient-sdk-linuxx64.zip && rm instantclient-sdk-linuxx64.zip
6666
mv instantclient_*_* /opt/oracle/instantclient
6767
# Interferes with libldap2 headers.
6868
rm /opt/oracle/instantclient/sdk/include/ldap.h

.github/actions/install-linux/action.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ runs:
1010
sudo chmod 777 /etc/php.d
1111
echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
1212
echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/pdo_mysql.ini
13-
echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
14-
echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Verify generated files are up to date
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: |
7+
set -x
8+
[[ "$OSTYPE" == "darwin"* ]] && export PATH="/usr/local/opt/bison/bin:$PATH"
9+
scripts/dev/genfiles
10+
Zend/zend_vm_gen.php
11+
build/gen_stub.php -f
12+
git add . -Nu && git diff --exit-code

.github/workflows/nightly.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
jobs:
77
GENERATE_MATRIX:
88
name: Generate Matrix
9+
if: github.repository_owner == 'php' || github.event_name == 'workflow_dispatch'
910
runs-on: ubuntu-latest
1011
outputs:
1112
branches: ${{ steps.set-matrix.outputs.branches }}
@@ -74,21 +75,26 @@ jobs:
7475
runTestsParameters: >-
7576
${{ matrix.run_tests_parameters }}
7677
-d zend_extension=opcache.so
78+
-d opcache.enable_cli=1
7779
-d opcache.jit_buffer_size=16M
7880
- name: Test OpCache
7981
uses: ./.github/actions/test-linux
8082
with:
8183
runTestsParameters: >-
8284
${{ matrix.run_tests_parameters }}
8385
-d zend_extension=opcache.so
86+
-d opcache.enable_cli=1
8487
- name: Test Function JIT
8588
uses: ./.github/actions/test-linux
8689
with:
8790
runTestsParameters: >-
8891
${{ matrix.run_tests_parameters }}
8992
-d zend_extension=opcache.so
93+
-d opcache.enable_cli=1
9094
-d opcache.jit_buffer_size=16M
9195
-d opcache.jit=1205
96+
- name: Verify generated files are up to date
97+
uses: ./.github/actions/verify-generated-files
9298
MACOS:
9399
needs: GENERATE_MATRIX
94100
if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
@@ -126,19 +132,24 @@ jobs:
126132
with:
127133
runTestsParameters: >-
128134
-d zend_extension=opcache.so
135+
-d opcache.enable_cli=1
129136
-d opcache.protect_memory=1
130137
-d opcache.jit_buffer_size=16M
131138
- name: Test OpCache
132139
uses: ./.github/actions/test-macos
133140
with:
134141
runTestsParameters: >-
135142
-d zend_extension=opcache.so
143+
-d opcache.enable_cli=1
136144
-d opcache.protect_memory=1
137145
- name: Test Function JIT
138146
uses: ./.github/actions/test-macos
139147
with:
140148
runTestsParameters: >-
141149
-d zend_extension=opcache.so
150+
-d opcache.enable_cli=1
142151
-d opcache.protect_memory=1
143152
-d opcache.jit_buffer_size=16M
144153
-d opcache.jit=1205
154+
- name: Verify generated files are up to date
155+
uses: ./.github/actions/verify-generated-files

.github/workflows/push.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ jobs:
5353
- name: Test Tracing JIT
5454
uses: ./.github/actions/test-linux
5555
with:
56-
runTestsParameters: -d zend_extension=opcache.so -d opcache.jit_buffer_size=16M
56+
runTestsParameters: >-
57+
-d zend_extension=opcache.so
58+
-d opcache.enable_cli=1
59+
-d opcache.jit_buffer_size=16M
60+
- name: Verify generated files are up to date
61+
uses: ./.github/actions/verify-generated-files
5762
MACOS_DEBUG_NTS:
5863
runs-on: macos-10.15
5964
steps:
@@ -78,5 +83,8 @@ jobs:
7883
with:
7984
runTestsParameters: >-
8085
-d zend_extension=opcache.so
86+
-d opcache.enable_cli=1
8187
-d opcache.protect_memory=1
8288
-d opcache.jit_buffer_size=16M
89+
- name: Verify generated files are up to date
90+
uses: ./.github/actions/verify-generated-files

NEWS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ PHP NEWS
1010
. Fixed bug GH-7771 (Fix filename/lineno of constant expressions). (ilutov)
1111
. Fixed bug GH-7792 (Improve class type in error messages). (ilutov)
1212

13+
- Curl:
14+
. Added support for CURLOPT_XFERINFOFUNCTION. (David Carlier)
15+
1316
- FPM:
1417
. Emit error for invalid port setting. (David Carlier)
1518
. Added extra check for FPM proc dumpable on SELinux based systems.
1619
(David Carlier)
20+
. Added support for listening queue on macOS. (David Carlier)
21+
. Changed default for listen.backlog on Linux to -1. (Cristian Rodríguez)
1722

1823
- Intl:
1924
. Update all grandfathered language tags with preferred values
@@ -31,6 +36,9 @@ PHP NEWS
3136
- Sodium:
3237
. Added sodium_crypto_stream_xchacha20_xor_ic(). (Scott)
3338

39+
- SQLite3:
40+
. Changed sqlite3.defensive from PHP_INI_SYSTEM to PHP_INI_USER. (bohwaz)
41+
3442
- Standard:
3543
. net_get_interfaces() also reports wireless network interfaces on Windows.
3644
(Yurun)

TSRM/TSRM.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate
288288
tsrm_resource_type *_tmp;
289289
_tmp = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count);
290290
if (!_tmp) {
291-
tsrm_mutex_unlock(tsmm_mutex);
292291
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate storage for resource"));
293292
*rsrc_id = 0;
293+
tsrm_mutex_unlock(tsmm_mutex);
294294
return 0;
295295
}
296296
resource_types_table = _tmp;
@@ -331,10 +331,10 @@ TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, siz
331331

332332
size = TSRM_ALIGNED_SIZE(size);
333333
if (tsrm_reserved_size - tsrm_reserved_pos < size) {
334-
tsrm_mutex_unlock(tsmm_mutex);
335334
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate space for fast resource"));
336335
*rsrc_id = 0;
337336
*offset = 0;
337+
tsrm_mutex_unlock(tsmm_mutex);
338338
return 0;
339339
}
340340

@@ -346,9 +346,9 @@ TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, siz
346346
tsrm_resource_type *_tmp;
347347
_tmp = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count);
348348
if (!_tmp) {
349-
tsrm_mutex_unlock(tsmm_mutex);
350349
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate storage for resource"));
351350
*rsrc_id = 0;
351+
tsrm_mutex_unlock(tsmm_mutex);
352352
return 0;
353353
}
354354
resource_types_table = _tmp;

UPGRADING

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ PHP 8.2 UPGRADE NOTES
3535
* SplFileObject::ftell()
3636
* SplFileObject::fgetc()
3737
* SplFileObject::fpassthru()
38+
. SplFileObject::hasChildren() now has a tentative return type of false,
39+
previously it was bool
40+
. SplFileObject::getChildren() now has a tentative return type of null,
41+
previously it was ?RecursiveIterator
3842

3943
========================================
4044
2. New Features
@@ -44,6 +48,8 @@ PHP 8.2 UPGRADE NOTES
4448
. Added the #[\SensitiveParameter] attribute to redact sensitive data in
4549
backtraces.
4650
RFC: https://wiki.php.net/rfc/redact_parameters_in_back_traces
51+
. It is now possible to use null and false as standalone types.
52+
RFC: https://wiki.php.net/rfc/null-false-standalone-types
4753

4854
- Curl:
4955
. Added CURLINFO_EFFECTIVE_METHOD option and returning the effective
@@ -158,6 +164,9 @@ PHP 8.2 UPGRADE NOTES
158164
- OCI8:
159165
. The minimum Oracle Client library version required is now 11.2.
160166

167+
- SQLite3:
168+
. sqlite3.defensive is now PHP_INI_USER.
169+
161170
- Standard:
162171
. getimagesize() now reports the actual image dimensions, bits and channels
163172
of AVIF images. Previously, the dimensions have been reported as 0x0, and
@@ -174,6 +183,9 @@ PHP 8.2 UPGRADE NOTES
174183
- COM_DOTNET:
175184
. LOCALE_NEUTRAL
176185

186+
- Curl:
187+
. CURLOPT_XFERINFOFUNCTION
188+
177189
- Sockets:
178190
. SO_INCOMING_CPU
179191

Zend/Optimizer/optimize_func_calls.c

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828
#include "zend_execute.h"
2929
#include "zend_vm.h"
3030

31-
#define ZEND_OP1_IS_CONST_STRING(opline) \
32-
(opline->op1_type == IS_CONST && \
33-
Z_TYPE(op_array->literals[(opline)->op1.constant]) == IS_STRING)
34-
#define ZEND_OP2_IS_CONST_STRING(opline) \
35-
(opline->op2_type == IS_CONST && \
36-
Z_TYPE(op_array->literals[(opline)->op2.constant]) == IS_STRING)
37-
3831
typedef struct _optimizer_call_info {
3932
zend_function *func;
4033
zend_op *opline;
@@ -139,6 +132,20 @@ static void zend_try_inline_call(zend_op_array *op_array, zend_op *fcall, zend_o
139132
}
140133
}
141134

135+
/* arg_num is 1-based here, to match SEND encoding. */
136+
static bool has_known_send_mode(const optimizer_call_info *info, uint32_t arg_num)
137+
{
138+
if (!info->func) {
139+
return false;
140+
}
141+
142+
/* For prototype functions we should not make assumptions about arguments that are not part of
143+
* the signature: And inheriting method can add an optional by-ref argument. */
144+
return !info->is_prototype
145+
|| arg_num <= info->func->common.num_args
146+
|| (info->func->common.fn_flags & ZEND_ACC_VARIADIC);
147+
}
148+
142149
void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
143150
{
144151
zend_op *opline = op_array->opcodes;
@@ -225,8 +232,8 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
225232
case ZEND_FETCH_STATIC_PROP_FUNC_ARG:
226233
case ZEND_FETCH_OBJ_FUNC_ARG:
227234
case ZEND_FETCH_DIM_FUNC_ARG:
228-
if (call_stack[call - 1].func
229-
&& call_stack[call - 1].func_arg_num != (uint32_t)-1) {
235+
if (call_stack[call - 1].func_arg_num != (uint32_t)-1
236+
&& has_known_send_mode(&call_stack[call - 1], call_stack[call - 1].func_arg_num)) {
230237
if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, call_stack[call - 1].func_arg_num)) {
231238
if (opline->opcode != ZEND_FETCH_STATIC_PROP_FUNC_ARG) {
232239
opline->opcode -= 9;
@@ -251,40 +258,37 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
251258
}
252259
break;
253260
case ZEND_SEND_VAL_EX:
254-
if (call_stack[call - 1].func) {
255-
if (opline->op2_type == IS_CONST) {
256-
call_stack[call - 1].try_inline = 0;
257-
break;
258-
}
261+
if (opline->op2_type == IS_CONST) {
262+
call_stack[call - 1].try_inline = 0;
263+
break;
264+
}
259265

260-
if (ARG_MUST_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {
261-
/* We won't convert it into_DO_FCALL to emit error at run-time */
262-
call_stack[call - 1].opline = NULL;
263-
} else {
266+
if (has_known_send_mode(&call_stack[call - 1], opline->op2.num)) {
267+
if (!ARG_MUST_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {
264268
opline->opcode = ZEND_SEND_VAL;
265269
}
266270
}
267271
break;
268272
case ZEND_CHECK_FUNC_ARG:
269-
if (call_stack[call - 1].func) {
270-
if (opline->op2_type == IS_CONST) {
271-
call_stack[call - 1].try_inline = 0;
272-
call_stack[call - 1].func_arg_num = (uint32_t)-1;
273-
break;
274-
}
273+
if (opline->op2_type == IS_CONST) {
274+
call_stack[call - 1].try_inline = 0;
275+
call_stack[call - 1].func_arg_num = (uint32_t)-1;
276+
break;
277+
}
275278

279+
if (has_known_send_mode(&call_stack[call - 1], opline->op2.num)) {
276280
call_stack[call - 1].func_arg_num = opline->op2.num;
277281
MAKE_NOP(opline);
278282
}
279283
break;
280284
case ZEND_SEND_VAR_EX:
281285
case ZEND_SEND_FUNC_ARG:
282-
if (call_stack[call - 1].func) {
283-
if (opline->op2_type == IS_CONST) {
284-
call_stack[call - 1].try_inline = 0;
285-
break;
286-
}
286+
if (opline->op2_type == IS_CONST) {
287+
call_stack[call - 1].try_inline = 0;
288+
break;
289+
}
287290

291+
if (has_known_send_mode(&call_stack[call - 1], opline->op2.num)) {
288292
call_stack[call - 1].func_arg_num = (uint32_t)-1;
289293
if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {
290294
opline->opcode = ZEND_SEND_REF;
@@ -294,12 +298,12 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
294298
}
295299
break;
296300
case ZEND_SEND_VAR_NO_REF_EX:
297-
if (call_stack[call - 1].func) {
298-
if (opline->op2_type == IS_CONST) {
299-
call_stack[call - 1].try_inline = 0;
300-
break;
301-
}
301+
if (opline->op2_type == IS_CONST) {
302+
call_stack[call - 1].try_inline = 0;
303+
break;
304+
}
302305

306+
if (has_known_send_mode(&call_stack[call - 1], opline->op2.num)) {
303307
if (ARG_MUST_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {
304308
opline->opcode = ZEND_SEND_VAR_NO_REF;
305309
} else if (ARG_MAY_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) {

Zend/Optimizer/sccp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,10 @@ static zval *value_from_type_and_range(sccp_ctx *ctx, int var_num, zval *tmp) {
17211721
}
17221722

17231723
if (!(info->type & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_NULL))) {
1724+
if (ssa->vars[var_num].definition >= 0
1725+
&& ctx->scdf.op_array->opcodes[ssa->vars[var_num].definition].opcode == ZEND_VERIFY_RETURN_TYPE) {
1726+
return NULL;
1727+
}
17241728
ZVAL_NULL(tmp);
17251729
return tmp;
17261730
}

Zend/Optimizer/ssa_integrity.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ void ssa_verify_integrity(zend_op_array *op_array, zend_ssa *ssa, const char *ex
176176
if ((type & MAY_BE_ARRAY_OF_ANY) && !(type & MAY_BE_ARRAY_KEY_ANY)) {
177177
FAIL("var " VARFMT " has array value type but not key type\n", VAR(i));
178178
}
179+
if ((type & MAY_BE_REF) && ssa->var_info[i].ce) {
180+
FAIL("var " VARFMT " may be ref but has ce\n", VAR(i));
181+
}
179182
}
180183

181184
/* Instructions */

Zend/Optimizer/zend_func_info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ ZEND_API uint32_t zend_get_func_info(
186186
/* It's allowed to override a method that return non-reference with a method that returns a reference */
187187
if (call_info->is_prototype && (ret & ~MAY_BE_REF)) {
188188
ret |= MAY_BE_REF;
189+
*ce = NULL;
189190
}
190191
}
191192
}

0 commit comments

Comments
 (0)