Skip to content

Commit 9c02766

Browse files
authored
Merge branch 'master' into improve-explode-error-message
2 parents 9533450 + 794a35c commit 9c02766

194 files changed

Lines changed: 3629 additions & 1335 deletions

File tree

Some content is hidden

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

NEWS

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ PHP NEWS
9696
. Added AES-SIV support. (jordikroon)
9797
. Implemented GH-20310 (No critical extension indication in
9898
openssl_x509_parse() output). (StephenWall)
99+
. Added TLS session resumption support for streams with new context options
100+
and Openssl\Session class. (Jakub Zelenka)
99101

100102
- PDO_PGSQL:
101103
. Clear session-local state disconnect-equivalent processing.
@@ -104,6 +106,10 @@ PHP NEWS
104106
- PGSQL:
105107
. Enabled 64 bits support for pg_lo_truncate()/pg_lo_tell()
106108
if the server supports it. (KentarouTakeda)
109+
. pg_fetch_object() now surfaces non-instantiable class errors
110+
before fetching, resolves the constructor via the get_constructor
111+
handler, and reports the empty-constructor ValueError on the
112+
$constructor_args argument. (David Carlier)
107113

108114
- Phar:
109115
. Support reference values in Phar::mungServer(). (ndossche)
@@ -182,6 +188,8 @@ PHP NEWS
182188
contains null bytes. (Weilin Du)
183189
. Improved explode() ValueError message when $separator is empty; suggests
184190
str_split() or mb_str_split(). (diegoasales)
191+
. proc_open() now raises a ValueError when the $cwd argument contains
192+
null bytes. (Weilin Du)
185193

186194
- Streams:
187195
. Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream
@@ -207,6 +215,9 @@ PHP NEWS
207215

208216
- Zlib:
209217
. deflate_init() now raises a TypeError when the value for option
210-
"strategy" is not of type int. (Weilin Du)
218+
"level", "memory", "window", or "strategy" is not of type int.
219+
(Weilin Du)
220+
. inflate_init() now raises a TypeError when the value for option
221+
"window" is not of type int. (Weilin Du)
211222

212223
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

UPGRADING

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ PHP 8.6 UPGRADE NOTES
4747
. Phar::mungServer() now raises a ValueError when an invalid
4848
argument value is passed instead of being silently ignored.
4949

50+
- PGSQL:
51+
. pg_fetch_object() now reports the ValueError for a non-empty
52+
$constructor_args on a class without a constructor on the
53+
$constructor_args argument instead of $class. Errors raised when
54+
the requested class is not instantiable (abstract, interface, enum)
55+
now surface before the row is fetched.
56+
5057
- Posix:
5158
. posix_access() now raises a ValueError when an invalid $flags
5259
argument value is passed.
@@ -95,6 +102,8 @@ PHP 8.6 UPGRADE NOTES
95102
argument value is passed.
96103
. scandir() now raises a ValueError when an invalid $sorting_order
97104
argument value is passed.
105+
. proc_open() now raises a ValueError when the $cwd argument contains
106+
null bytes.
98107

99108
- Zip:
100109
. ZipArchive::extractTo now raises a TypeError for the
@@ -103,7 +112,9 @@ PHP 8.6 UPGRADE NOTES
103112

104113
- Zlib:
105114
. deflate_init() now raises a TypeError when the value for option
106-
"strategy" is not of type int.
115+
"level", "memory", "window", or "strategy" is not of type int.
116+
. inflate_init() now raises a TypeError when the value for option
117+
"window" is not of type int.
107118

108119
========================================
109120
2. New Features
@@ -132,6 +143,15 @@ PHP 8.6 UPGRADE NOTES
132143
. Added extra info about error location to the JSON error messages returned
133144
from json_last_error_msg() and JsonException message.
134145

146+
- OpenSSL:
147+
. Added TLS session resumption support for streams with new stream context
148+
options: session_data, session_new_cb, session_cache, session_cache_size,
149+
session_timeout, session_id_context, session_get_cb, session_remove_cb,
150+
and num_tickets. This allows saving and restoring client sessions across
151+
requests, implementing custom server-side session storage, and controlling
152+
session cache behavior.
153+
RFC: https://wiki.php.net/rfc/tls_session_resumption
154+
135155
- Phar:
136156
. Overriding the getMTime() and getPathname() methods of SplFileInfo now
137157
influences the result of the phar buildFrom family of functions.
@@ -227,6 +247,11 @@ PHP 8.6 UPGRADE NOTES
227247
7. New Classes and Interfaces
228248
========================================
229249

250+
- OpenSSL:
251+
. Openssl\OpensslException
252+
. Openssl\Session
253+
RFC: https://wiki.php.net/rfc/tls_session_resumption
254+
230255
- Standard:
231256
. enum SortDirection
232257
RFC: https://wiki.php.net/rfc/sort_direction_enum

UPGRADING.INTERNALS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES
9696
and ZEND_PARSE_PARAMS_THROW have been removed due to being misleading,
9797
since ZPP always throws, unless ZEND_PARSE_PARAMS_QUIET is given. Use
9898
the non-throw versions.
99+
. The XtOffsetOf() alias of C’s offsetof() macro has been removed. Use
100+
offsetof() directly.
99101

100102
========================
101103
2. Build system changes

Zend/Optimizer/block_pass.c

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -344,59 +344,6 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
344344
}
345345
break;
346346

347-
#if 0
348-
/* pre-evaluate functions:
349-
constant(x)
350-
function_exists(x)
351-
extension_loaded(x)
352-
BAD: interacts badly with Accelerator
353-
*/
354-
if((opline->op1_type & IS_VAR) &&
355-
VAR_SOURCE(opline->op1) && VAR_SOURCE(opline->op1)->opcode == ZEND_DO_CF_FCALL &&
356-
VAR_SOURCE(opline->op1)->extended_value == 1) {
357-
zend_op *fcall = VAR_SOURCE(opline->op1);
358-
zend_op *sv = fcall-1;
359-
if(sv >= block->start_opline && sv->opcode == ZEND_SEND_VAL &&
360-
sv->op1_type == IS_CONST && Z_TYPE(OPLINE_OP1_LITERAL(sv)) == IS_STRING &&
361-
Z_LVAL(OPLINE_OP2_LITERAL(sv)) == 1
362-
) {
363-
zval *arg = &OPLINE_OP1_LITERAL(sv);
364-
char *fname = FUNCTION_CACHE->funcs[Z_LVAL(ZEND_OP1_LITERAL(fcall))].function_name;
365-
size_t flen = FUNCTION_CACHE->funcs[Z_LVAL(ZEND_OP1_LITERAL(fcall))].name_len;
366-
if((flen == sizeof("function_exists")-1 && zend_binary_strcasecmp(fname, flen, "function_exists", sizeof("function_exists")-1) == 0) ||
367-
(flen == sizeof("is_callable")-1 && zend_binary_strcasecmp(fname, flen, "is_callable", sizeof("is_callable")-1) == 0)
368-
) {
369-
zend_function *function;
370-
if((function = zend_hash_find_ptr(EG(function_table), Z_STR_P(arg))) != NULL) {
371-
literal_dtor(arg);
372-
MAKE_NOP(sv);
373-
MAKE_NOP(fcall);
374-
LITERAL_BOOL(opline->op1, 1);
375-
opline->op1_type = IS_CONST;
376-
}
377-
} else if(flen == sizeof("constant")-1 && zend_binary_strcasecmp(fname, flen, "constant", sizeof("constant")-1) == 0) {
378-
zval c;
379-
if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, true ELS_CC)) {
380-
literal_dtor(arg);
381-
MAKE_NOP(sv);
382-
MAKE_NOP(fcall);
383-
ZEND_OP1_LITERAL(opline) = zend_optimizer_add_literal(op_array, &c);
384-
/* no copy ctor - get already copied it */
385-
opline->op1_type = IS_CONST;
386-
}
387-
} else if(flen == sizeof("extension_loaded")-1 && zend_binary_strcasecmp(fname, flen, "extension_loaded", sizeof("extension_loaded")-1) == 0) {
388-
if(zend_hash_exists(&module_registry, Z_STR_P(arg))) {
389-
literal_dtor(arg);
390-
MAKE_NOP(sv);
391-
MAKE_NOP(fcall);
392-
LITERAL_BOOL(opline->op1, 1);
393-
opline->op1_type = IS_CONST;
394-
}
395-
}
396-
}
397-
}
398-
#endif
399-
400347
case ZEND_FETCH_LIST_R:
401348
case ZEND_FETCH_LIST_W:
402349
if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {

Zend/Optimizer/zend_optimizer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ static bool zend_optimizer_ignore_class(zval *ce_zv, const zend_string *filename
780780
if (CG(compiler_options) & ZEND_COMPILE_WITH_FILE_CACHE) {
781781
return true;
782782
}
783-
const Bucket *ce_bucket = (const Bucket*)((uintptr_t)ce_zv - XtOffsetOf(Bucket, val));
783+
const Bucket *ce_bucket = (const Bucket*)((uintptr_t)ce_zv - offsetof(Bucket, val));
784784
size_t offset = ce_bucket - EG(class_table)->arData;
785785
if (offset < EG(persistent_classes_count)) {
786786
return false;
@@ -801,7 +801,7 @@ static bool zend_optimizer_ignore_function(zval *fbc_zv, const zend_string *file
801801
if (CG(compiler_options) & ZEND_COMPILE_WITH_FILE_CACHE) {
802802
return true;
803803
}
804-
const Bucket *fbc_bucket = (const Bucket*)((uintptr_t)fbc_zv - XtOffsetOf(Bucket, val));
804+
const Bucket *fbc_bucket = (const Bucket*)((uintptr_t)fbc_zv - offsetof(Bucket, val));
805805
size_t offset = fbc_bucket - EG(function_table)->arData;
806806
if (offset < EG(persistent_functions_count)) {
807807
return false;

Zend/zend_API.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -509,35 +509,33 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32
509509
return !EG(exception);
510510
}
511511

512-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(const zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
512+
ZEND_API zpp_parse_bool_status ZEND_FASTCALL zend_parse_arg_bool_weak(const zval *arg, uint32_t arg_num) /* {{{ */
513513
{
514514
if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
515515
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) {
516-
return 0;
516+
return ZPP_PARSE_BOOL_STATUS_ERROR;
517517
}
518-
*dest = zend_is_true(arg);
519-
} else {
520-
return 0;
518+
return zend_is_true(arg);
521519
}
522-
return 1;
520+
return ZPP_PARSE_BOOL_STATUS_ERROR;
523521
}
524522
/* }}} */
525523

526-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(const zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
524+
ZEND_API zpp_parse_bool_status ZEND_FASTCALL zend_parse_arg_bool_slow(const zval *arg, uint32_t arg_num) /* {{{ */
527525
{
528526
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
529-
return 0;
527+
return ZPP_PARSE_BOOL_STATUS_ERROR;
530528
}
531-
return zend_parse_arg_bool_weak(arg, dest, arg_num);
529+
return zend_parse_arg_bool_weak(arg, arg_num);
532530
}
533531
/* }}} */
534532

535-
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_bool_slow(const zval *arg, bool *dest, uint32_t arg_num)
533+
ZEND_API zpp_parse_bool_status ZEND_FASTCALL zend_flf_parse_arg_bool_slow(const zval *arg, uint32_t arg_num)
536534
{
537535
if (UNEXPECTED(ZEND_FLF_ARG_USES_STRICT_TYPES())) {
538-
return 0;
536+
return ZPP_PARSE_BOOL_STATUS_ERROR;
539537
}
540-
return zend_parse_arg_bool_weak(arg, dest, arg_num);
538+
return zend_parse_arg_bool_weak(arg, arg_num);
541539
}
542540

543541
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, zend_long *dest, uint32_t arg_num) /* {{{ */
@@ -624,44 +622,46 @@ ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_long_slow(const zval *arg, zend_l
624622
return zend_parse_arg_long_weak(arg, dest, arg_num);
625623
}
626624

627-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, double *dest, uint32_t arg_num) /* {{{ */
625+
ZEND_API double ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, uint32_t arg_num) /* {{{ */
628626
{
629627
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
630-
*dest = (double)Z_LVAL_P(arg);
628+
return (double)Z_LVAL_P(arg);
631629
} else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
632630
zend_long l;
631+
double dval;
633632
uint8_t type;
634633

635-
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, dest)) != IS_DOUBLE)) {
634+
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, &dval)) != IS_DOUBLE)) {
636635
if (EXPECTED(type != 0)) {
637-
*dest = (double)(l);
636+
return (double)(l);
638637
} else {
639-
return 0;
638+
return NAN;
640639
}
640+
} else {
641+
return dval;
641642
}
642643
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
643644
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("float", arg_num)) {
644-
return 0;
645+
return NAN;
645646
}
646-
*dest = 0.0;
647+
return 0.0;
647648
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
648-
*dest = 1.0;
649+
return 1.0;
649650
} else {
650-
return 0;
651+
return NAN;
651652
}
652-
return 1;
653653
}
654654
/* }}} */
655655

656-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(const zval *arg, double *dest, uint32_t arg_num) /* {{{ */
656+
ZEND_API double ZEND_FASTCALL zend_parse_arg_double_slow(const zval *arg, uint32_t arg_num) /* {{{ */
657657
{
658658
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
659659
/* SSTH Exception: IS_LONG may be accepted instead as IS_DOUBLE */
660-
*dest = (double)Z_LVAL_P(arg);
660+
return (double)Z_LVAL_P(arg);
661661
} else if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
662-
return 0;
662+
return NAN;
663663
}
664-
return zend_parse_arg_double_weak(arg, dest, arg_num);
664+
return zend_parse_arg_double_weak(arg, arg_num);
665665
}
666666
/* }}} */
667667

@@ -728,58 +728,58 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow(zval *arg, zval **
728728
return true;
729729
}
730730

731-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest, uint32_t arg_num) /* {{{ */
731+
ZEND_API zend_string* ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, uint32_t arg_num) /* {{{ */
732732
{
733733
if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
734734
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string", arg_num)) {
735-
return 0;
735+
return NULL;
736736
}
737737
convert_to_string(arg);
738-
*dest = Z_STR_P(arg);
738+
return Z_STR_P(arg);
739739
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
740740
zend_object *zobj = Z_OBJ_P(arg);
741741
zval obj;
742742
if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) {
743743
OBJ_RELEASE(zobj);
744744
ZVAL_COPY_VALUE(arg, &obj);
745-
*dest = Z_STR_P(arg);
746-
return 1;
745+
return Z_STR_P(arg);
747746
}
748-
return 0;
747+
return NULL;
749748
} else {
750-
return 0;
749+
return NULL;
751750
}
752-
return 1;
753751
}
754752
/* }}} */
755753

756-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num) /* {{{ */
754+
ZEND_API zend_string* ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, uint32_t arg_num) /* {{{ */
757755
{
758756
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
759-
return 0;
757+
return NULL;
760758
}
761-
return zend_parse_arg_str_weak(arg, dest, arg_num);
759+
return zend_parse_arg_str_weak(arg, arg_num);
762760
}
763761
/* }}} */
764762

765-
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num)
763+
ZEND_API zend_string* ZEND_FASTCALL zend_flf_parse_arg_str_slow(zval *arg, uint32_t arg_num)
766764
{
767765
if (UNEXPECTED(ZEND_FLF_ARG_USES_STRICT_TYPES())) {
768-
return 0;
766+
return NULL;
769767
}
770-
return zend_parse_arg_str_weak(arg, dest, arg_num);
768+
return zend_parse_arg_str_weak(arg, arg_num);
771769
}
772770

773771
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long, uint32_t arg_num) /* {{{ */
774772
{
773+
zend_string *str;
775774
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
776775
return 0;
777776
}
778777
if (zend_parse_arg_long_weak(arg, dest_long, arg_num)) {
779778
*dest_str = NULL;
780779
return 1;
781-
} else if (zend_parse_arg_str_weak(arg, dest_str, arg_num)) {
780+
} else if ((str = zend_parse_arg_str_weak(arg, arg_num)) != NULL) {
782781
*dest_long = 0;
782+
*dest_str = str;
783783
return 1;
784784
} else {
785785
return 0;

0 commit comments

Comments
 (0)