Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ PHP NEWS
- Core:
. Non-canonical cast names (boolean), (integer), (double), and (binary) have
been deprecated. (Girgias)
. The $exclude_disabled parameter of the get_defined_functions() function has
been deprecated, as it no longer has any effect since PHP 8.0. (Girgias)

- FileInfo
. The finfo_close() function has been deprecated. (timwolla)

- Intl:
. Intl's internal error mechanism has been modernized so that it
indicates more accurately which call site caused what error.
Moreover, some ext/date exceptions have been wrapped inside a
IntlException now. (Girgias)

- MySQLi:
. The mysqli_execute() alias function has been deprecated. (timwolla)

Expand All @@ -22,6 +30,17 @@ PHP NEWS
. The setAccessible() methods of various Reflection objects have been
deprecated, as those no longer have an effect. (timwolla)

- SPL:
. Unregistering all autoloaders by passing the spl_autoload_call() function
as a callback argument to spl_autoload_unregister() has been deprecated.
Instead if this is needed, one should iterate over the return value of
spl_autoload_functions() and call spl_autoload_unregister() on each
value. (Girgias)
. The SplObjectStorage::contains(), SplObjectStorage::attach(), and
SplObjectStorage::detach() methods have been deprecated in favour of
SplObjectStorage::offsetExists(), SplObjectStorage::offsetSet(), and
SplObjectStorage::offsetUnset() respectively. (Girgias)

- Standard:
. The socket_set_timeout() alias function has been deprecated. (timwolla)

Expand Down
21 changes: 21 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ PHP 8.5 UPGRADE NOTES
. Non-canonical cast names (boolean), (integer), (double), and (binary) have
been deprecated, use (bool), (int), (float), and (string) respectively.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_non-standard_cast_names
. The $exclude_disabled parameter of the get_defined_functions() function has
been deprecated, as it no longer has any effect since PHP 8.0.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_exclude_disabled_parameter_of_get_defined_functions

- FileInfo:
. The finfo_close() function has been deprecated.
Expand Down Expand Up @@ -346,6 +349,18 @@ PHP 8.5 UPGRADE NOTES
deprecated, as those no longer have an effect.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible

- SPL:
. Unregistering all autoloaders by passing the spl_autoload_call() function
as a callback argument to spl_autoload_unregister() has been deprecated.
Instead if this is needed, one should iterate over the return value of
spl_autoload_functions() and call spl_autoload_unregister() on each value.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_spl_autoload_call_to_spl_autoload_unregister
. The SplObjectStorage::contains(), SplObjectStorage::attach(), and
SplObjectStorage::detach() methods have been deprecated in favour of
SplObjectStorage::offsetExists(), SplObjectStorage::offsetSet(), and
SplObjectStorage::offsetUnset() respectively.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_splobjectstoragecontains_splobjectstorageattach_and_splobjectstoragedetach

- Standard:
. The socket_set_timeout() alias function has been deprecated.
Use stream_set_timeout() instead.
Expand Down Expand Up @@ -575,6 +590,12 @@ PHP 8.5 UPGRADE NOTES
. The return type of finfo_close() has been changed to true, rather
than bool.

- Intl:
. Intl's internal error mechanism has been modernized so that it
indicates more accurately which call site caused what error.
Moreover, some ext/date exceptions have been wrapped inside a
IntlException now.

- Lexbor:
. An always enabled lexbor extension is added. It contains the lexbor
library that was separated from ext/dom for being reused among other
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ PHP 8.5 INTERNALS UPGRADE NOTES
be heap-allocated and stored in the pointer as a minimal change to keep
compatibility.

- Hash
. Hash functions now use proper hash_spec_result enum for return values
instead of using SUCCESS and FAILURE.

- Zend
. Added zend_safe_assign_to_variable_noref() function to safely assign
a value to a non-reference zval.
Expand Down
16 changes: 0 additions & 16 deletions Zend/tests/bug79668.phpt

This file was deleted.

4 changes: 2 additions & 2 deletions Zend/tests/enum/spl-object-storage.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ $storage[Foo::Baz] = 'Baz';
var_dump($storage[Foo::Bar]);
var_dump($storage[Foo::Baz]);

var_dump($storage->contains(Foo::Bar));
var_dump($storage->contains(Foo::Qux));
var_dump($storage->offsetExists(Foo::Bar));
var_dump($storage->offsetExists(Foo::Qux));

$serialized = serialize($storage);
var_dump($serialized);
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1483,15 +1483,15 @@ ZEND_FUNCTION(get_defined_functions)
zval internal, user;
zend_string *key;
zend_function *func;
bool exclude_disabled = 1;
bool exclude_disabled = true;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &exclude_disabled) == FAILURE) {
RETURN_THROWS();
}

if (exclude_disabled == 0) {
if (ZEND_NUM_ARGS() == 1) {
zend_error(E_DEPRECATED,
"get_defined_functions(): Setting $exclude_disabled to false has no effect");
"get_defined_functions(): The $exclude_disabled parameter has no effect since PHP 8.0");
}

array_init(&internal);
Expand Down
60 changes: 28 additions & 32 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,20 @@ static void one_to_buffer(size_t sz, unsigned char *buf, uint64_t val) {
significant bits first. This allows 32-bit and 64-bit architectures to
interchange serialized HashContexts. */

PHP_HASH_API zend_result php_hash_serialize_spec(const php_hashcontext_object *hash, zval *zv, const char *spec) /* {{{ */
PHP_HASH_API hash_spec_result php_hash_serialize_spec(const php_hashcontext_object *hash, zval *zv, const char *spec) /* {{{ */
{
size_t pos = 0, max_alignment = 1;
unsigned char *buf = (unsigned char *) hash->context;
zval tmp;
if (buf == NULL) {
return FAILURE;
return HASH_SPEC_FAILURE;
}
array_init(zv);
while (*spec != '\0' && *spec != '.') {
char spec_ch = *spec;
size_t sz, count = parse_serialize_spec(&spec, &pos, &sz, &max_alignment);
if (pos + count * sz > hash->ops->context_size) {
return FAILURE;
return HASH_SPEC_FAILURE;
}
if (isupper((unsigned char) spec_ch)) {
pos += count * sz;
Expand All @@ -265,38 +265,33 @@ PHP_HASH_API zend_result php_hash_serialize_spec(const php_hashcontext_object *h
}
}
if (*spec == '.' && align_to(pos, max_alignment) != hash->ops->context_size) {
return FAILURE;
return HASH_SPEC_FAILURE;
}
return SUCCESS;
return HASH_SPEC_SUCCESS;
}
/* }}} */

/* Unserialize a hash context serialized by `php_hash_serialize_spec` with `spec`.
Returns SUCCESS on success and a negative error code on failure.
Codes: FAILURE (-1) == generic failure
-999 == spec wrong size for context
-1000 - POS == problem at byte offset POS */

PHP_HASH_API int php_hash_unserialize_spec(php_hashcontext_object *hash, const zval *zv, const char *spec) /* {{{ */
/* Unserialize a hash context serialized by `php_hash_serialize_spec` with `spec`. */
PHP_HASH_API hash_spec_result php_hash_unserialize_spec(php_hashcontext_object *hash, const zval *zv, const char *spec) /* {{{ */
{
size_t pos = 0, max_alignment = 1, j = 0;
unsigned char *buf = (unsigned char *) hash->context;
zval *elt;
if (Z_TYPE_P(zv) != IS_ARRAY) {
return FAILURE;
return HASH_SPEC_FAILURE;
}
while (*spec != '\0' && *spec != '.') {
char spec_ch = *spec;
size_t sz, count = parse_serialize_spec(&spec, &pos, &sz, &max_alignment);
if (pos + count * sz > hash->ops->context_size) {
return -999;
return WRONG_CONTEXT_SIZE;
}
if (isupper((unsigned char) spec_ch)) {
pos += count * sz;
} else if (sz == 1 && count > 1) {
elt = zend_hash_index_find(Z_ARRVAL_P(zv), j);
if (!elt || Z_TYPE_P(elt) != IS_STRING || Z_STRLEN_P(elt) != count) {
return -1000 - pos;
return BYTE_OFFSET_POS_ERROR - pos;
}
++j;
memcpy(buf + pos, Z_STRVAL_P(elt), count);
Expand All @@ -306,14 +301,14 @@ PHP_HASH_API int php_hash_unserialize_spec(php_hashcontext_object *hash, const z
uint64_t val;
elt = zend_hash_index_find(Z_ARRVAL_P(zv), j);
if (!elt || Z_TYPE_P(elt) != IS_LONG) {
return -1000 - pos;
return BYTE_OFFSET_POS_ERROR - pos;
}
++j;
val = (uint32_t) Z_LVAL_P(elt);
if (sz == 8) {
elt = zend_hash_index_find(Z_ARRVAL_P(zv), j);
if (!elt || Z_TYPE_P(elt) != IS_LONG) {
return -1000 - pos;
return BYTE_OFFSET_POS_ERROR - pos;
}
++j;
val += ((uint64_t) Z_LVAL_P(elt)) << 32;
Expand All @@ -325,31 +320,32 @@ PHP_HASH_API int php_hash_unserialize_spec(php_hashcontext_object *hash, const z
}
}
if (*spec == '.' && align_to(pos, max_alignment) != hash->ops->context_size) {
return -999;
return WRONG_CONTEXT_SIZE;
}
return SUCCESS;

return HASH_SPEC_SUCCESS;
}
/* }}} */

PHP_HASH_API zend_result php_hash_serialize(const php_hashcontext_object *hash, zend_long *magic, zval *zv) /* {{{ */
PHP_HASH_API hash_spec_result php_hash_serialize(const php_hashcontext_object *hash, zend_long *magic, zval *zv) /* {{{ */
{
if (hash->ops->serialize_spec) {
*magic = PHP_HASH_SERIALIZE_MAGIC_SPEC;
return php_hash_serialize_spec(hash, zv, hash->ops->serialize_spec);
} else {
return FAILURE;
}
if (!hash->ops->serialize_spec) {
return HASH_SPEC_FAILURE;
}

*magic = PHP_HASH_SERIALIZE_MAGIC_SPEC;
return php_hash_serialize_spec(hash, zv, hash->ops->serialize_spec);
}
/* }}} */

PHP_HASH_API int php_hash_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv) /* {{{ */
PHP_HASH_API hash_spec_result php_hash_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv) /* {{{ */
{
if (hash->ops->serialize_spec
&& magic == PHP_HASH_SERIALIZE_MAGIC_SPEC) {
return php_hash_unserialize_spec(hash, zv, hash->ops->serialize_spec);
} else {
return FAILURE;
}

return HASH_SPEC_FAILURE;
}
/* }}} */

Expand Down Expand Up @@ -1475,7 +1471,7 @@ PHP_METHOD(HashContext, __serialize)
ZVAL_LONG(&tmp, hash->options);
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);

if (hash->ops->hash_serialize(hash, &magic, &tmp) != SUCCESS) {
if (hash->ops->hash_serialize(hash, &magic, &tmp) != HASH_SPEC_SUCCESS) {
goto serialize_failure;
}
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
Expand Down Expand Up @@ -1504,7 +1500,7 @@ PHP_METHOD(HashContext, __unserialize)
HashTable *data;
zval *algo_zv, *magic_zv, *options_zv, *hash_zv, *members_zv;
zend_long magic, options;
int unserialize_result;
hash_spec_result unserialize_result;
const php_hash_ops *ops;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &data) == FAILURE) {
Expand Down Expand Up @@ -1553,7 +1549,7 @@ PHP_METHOD(HashContext, __unserialize)
ops->hash_init(hash->context, NULL);

unserialize_result = ops->hash_unserialize(hash, magic, hash_zv);
if (unserialize_result != SUCCESS) {
if (unserialize_result != HASH_SPEC_SUCCESS) {
zend_throw_exception_ex(NULL, 0, "Incomplete or ill-formed serialization data (\"%s\" code %d)", ops->algo, unserialize_result);
/* free context */
php_hashcontext_dtor(Z_OBJ_P(object));
Expand Down
12 changes: 6 additions & 6 deletions ext/hash/hash_gost.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,17 @@ PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context)
ZEND_SECURE_ZERO(context, sizeof(*context));
}

static int php_gost_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv)
static hash_spec_result php_gost_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv)
{
PHP_GOST_CTX *ctx = (PHP_GOST_CTX *) hash->context;
int r = FAILURE;
hash_spec_result r = HASH_SPEC_FAILURE;
if (magic == PHP_HASH_SERIALIZE_MAGIC_SPEC
&& (r = php_hash_unserialize_spec(hash, zv, PHP_GOST_SPEC)) == SUCCESS
&& (r = php_hash_unserialize_spec(hash, zv, PHP_GOST_SPEC)) == HASH_SPEC_SUCCESS
&& ctx->length < sizeof(ctx->buffer)) {
return SUCCESS;
} else {
return r != SUCCESS ? r : -2000;
return HASH_SPEC_SUCCESS;
}

return r != HASH_SPEC_SUCCESS ? r : CONTEXT_VALIDATION_FAILURE;
}

const php_hash_ops php_hash_gost_ops = {
Expand Down
14 changes: 7 additions & 7 deletions ext/hash/hash_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const php_hash_ops php_hash_md4_ops = {
1
};

static int php_md2_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv);
static hash_spec_result php_md2_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv);

const php_hash_ops php_hash_md2_ops = {
"md2",
Expand Down Expand Up @@ -356,15 +356,15 @@ PHP_HASH_API void PHP_MD2Final(unsigned char output[16], PHP_MD2_CTX *context)
memcpy(output, context->state, 16);
}

static int php_md2_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv)
static hash_spec_result php_md2_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv)
{
PHP_MD2_CTX *ctx = (PHP_MD2_CTX *) hash->context;
int r = FAILURE;
hash_spec_result r = HASH_SPEC_FAILURE;
if (magic == PHP_HASH_SERIALIZE_MAGIC_SPEC
&& (r = php_hash_unserialize_spec(hash, zv, PHP_MD2_SPEC)) == SUCCESS
&& (r = php_hash_unserialize_spec(hash, zv, PHP_MD2_SPEC)) == HASH_SPEC_SUCCESS
&& (unsigned char) ctx->in_buffer < sizeof(ctx->buffer)) {
return SUCCESS;
} else {
return r != SUCCESS ? r : -2000;
return HASH_SPEC_SUCCESS;
}

return r != HASH_SPEC_SUCCESS ? r : CONTEXT_VALIDATION_FAILURE;
}
Loading
Loading