From f37b1654039cc991b682d2c03a3adfcb9e4c9f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 27 Jan 2025 13:41:41 +0100 Subject: [PATCH 1/2] Fix `#[\Deprecated]` for `__call()` and `__callStatic()` (#17592) * Fix `#[\Deprecated]` for `__call()` and `__callStatic()` Fixes php/php-src#17597. * Do not duplicate the `attributes` table in `zend_get_call_trampoline_func()` --- NEWS | 2 ++ .../deprecated/functions/magic_call.phpt | 24 +++++++++++++++++++ Zend/zend_object_handlers.c | 8 ++++++- Zend/zend_object_handlers.h | 5 ++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/attributes/deprecated/functions/magic_call.phpt diff --git a/NEWS b/NEWS index ac5d3d4c01a2d..8a81b22d9bc7d 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,8 @@ PHP NEWS (nielsdos, ilutov) . Fix may_have_extra_named_args flag for ZEND_AST_UNPACK. (nielsdos) . Fix NULL arithmetic in System V shared memory emulation for Windows. (cmb) + . Fixed bug GH-17597 (#[\Deprecated] does not work for __call() and + __callStatic()). (timwolla) - DOM: . Fixed bug GH-17397 (Assertion failure ext/dom/php_dom.c). (nielsdos) diff --git a/Zend/tests/attributes/deprecated/functions/magic_call.phpt b/Zend/tests/attributes/deprecated/functions/magic_call.phpt new file mode 100644 index 0000000000000..b56d3a1deb716 --- /dev/null +++ b/Zend/tests/attributes/deprecated/functions/magic_call.phpt @@ -0,0 +1,24 @@ +--TEST-- +#[\Deprecated]: __call() and __callStatic() +--FILE-- +test(); +Clazz::test2(); + +?> +--EXPECTF-- +Deprecated: Method Clazz::test() is deprecated in %s + +Deprecated: Method Clazz::test2() is deprecated, due to some reason in %s on line %d diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index f08685092745a..68d21d25253a4 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1617,7 +1617,13 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE | ZEND_ACC_PUBLIC | ZEND_ACC_VARIADIC - | (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE); + | (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_DEPRECATED)); + if (fbc->common.attributes) { + func->attributes = fbc->common.attributes; + GC_TRY_ADDREF(func->attributes); + } else { + func->attributes = NULL; + } if (is_static) { func->fn_flags |= ZEND_ACC_STATIC; } diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index f36eb765c24a5..2fc59d5020c25 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -339,7 +339,12 @@ ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_p } while (0) #define zend_free_trampoline(func) do { \ + HashTable *attributes = (func)->common.attributes; \ + if (attributes && !(GC_FLAGS(attributes) & GC_IMMUTABLE) && !GC_DELREF(attributes)) { \ + zend_array_destroy(attributes); \ + } \ if ((func) == &EG(trampoline)) { \ + EG(trampoline).common.attributes = NULL; \ EG(trampoline).common.function_name = NULL; \ } else { \ efree(func); \ From c99fb059295ed14034be17904f95e90ea80bb917 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 24 Jan 2025 14:39:30 +0100 Subject: [PATCH 2/2] Fix mysql mysql_native_password error on CircleCI This is already fixed in higher branches. We'll need to fix this properly when upgrading to MySQL 8.4, which we should do soon as 8.3 is already EOL. Closes GH-17560 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2320d2baca9c2..d9ad3f7c0a658 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ jobs: resource_class: arm.medium docker: - image: cimg/base:current-22.04 - - image: mysql:8 + - image: mysql:8.3 environment: MYSQL_ALLOW_EMPTY_PASSWORD: true MYSQL_ROOT_PASSWORD: ''