Commit Graph

669 Commits

Author SHA1 Message Date
Ilija Tovilo
4182813ebf
Call cast_object handler from get_properties_for
Fixes GH-11547
Closes GH-11583
2023-07-25 17:59:44 +02:00
Dmitry Stogov
0660fb5282 Merge branch 'PHP-8.2'
* PHP-8.2:
  Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048)
2023-04-10 23:25:42 +03:00
Dmitry Stogov
e14ac1caee Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048)
2023-04-10 23:25:08 +03:00
Dmitry Stogov
0c65b396d6
Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048) 2023-04-10 23:19:17 +03:00
Dmitry Stogov
24acb4f134
Delay destructor for zend_std_write_property 2023-04-04 18:55:47 +02:00
Ilija Tovilo
f1333bc9fe
Merge branch 'PHP-8.2'
* PHP-8.2:
  Reset EG(trampoline).op_array.last_var that FFI may modify
2023-03-27 23:00:12 +02:00
Ilija Tovilo
69c57bea3d
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Reset EG(trampoline).op_array.last_var that FFI may modify
2023-03-27 22:59:58 +02:00
Ilija Tovilo
4e0bd03681
Reset EG(trampoline).op_array.last_var that FFI may modify
Closes GH-10916
2023-03-27 22:59:00 +02:00
Máté Kocsis
e053ba0a3a
Do not allow side-effects when readonly property modification fails (#10757) 2023-03-03 19:53:42 +01:00
Máté Kocsis
3bcf2c3755
Allow readonly properties to be reinitialized once during cloning (#10389)
RFC: https://wiki.php.net/rfc/readonly_amendments
2023-02-28 22:54:38 +01:00
Max Kellermann
d5c649b36b
zend_compiler, ...: use uint8_t instead of zend_uchar (#10621)
`zend_uchar` suggests that the value is an ASCII character, but here,
it's about very small integers.  This is misleading, so let's use a
C99 integer instead.

On all architectures currently supported by PHP, `zend_uchar` and
`uint8_t` are identical.  This change is only about code readability.
2023-02-23 14:56:54 +00:00
Max Kellermann
413844d626
Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t (#10597)
These types are standard C99.

For compatibility with out-of-tree extensions, keep the typedefs
in main/php.h.
2023-02-18 19:31:28 +00:00
rj1
d2cdfdbe44
fixed some misspellings (#10503) 2023-02-04 07:03:10 +00:00
Ilija Tovilo
47ed1904ef
Fix use-after-free in write_property when object is released
Fixes GH-10169
Closes GH-10179
2023-02-02 20:03:50 +01:00
Niels Dossche
8d21a6b2ab
Fix UNEXPECTED() paren mistakes.
This corrects the paren placement to the intended one.
As these functions use zend_result, the success value is zero. Therefore
this has no functional change. The only difference is that this now
hints the compiler optimizer correctly.

Closes GH-10364.
2023-01-18 15:14:44 +01:00
George Peter Banyard
6556601b45
Add some const qualifiers and better return types to zend_object_handlers.h (#10330)
I initially wanted to add them to the zend_strings but because they are used in zend_hash_find() which might modify the hash field.
2023-01-16 13:55:12 +00:00
Christoph M. Becker
c8955c078a
Revert GH-10220
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491.
This reverts commit 588a07f737.
This reverts commit f377e15751.
This reverts commit b4ba16fe18.
This reverts commit 694ec1deea.
This reverts commit 6b34de8eba.
This reverts commit aa1cd02a43.
This reverts commit 308fd311ea.
This reverts commit 16203b53e1.
This reverts commit 738fb5ca54.
This reverts commit 9fdbefacd3.
This reverts commit cd4a7c1d90.
This reverts commit 928685eba2.
This reverts commit 01e5ffc85c.
2023-01-16 12:27:33 +01:00
Max Kellermann
b4ba16fe18 Zend/zend_object_handlers: include cleanup 2023-01-10 14:19:03 +00:00
George Peter Banyard
3b8327a4e3 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10251: Assertion `(flag & (1<<3)) == 0' failed.
  Fix GH-9710: phpdbg memory leaks by option "-h"
2023-01-08 16:12:21 +00:00
George Peter Banyard
e308dc0635 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10251: Assertion `(flag & (1<<3)) == 0' failed.
  Fix GH-9710: phpdbg memory leaks by option "-h"
2023-01-08 16:11:46 +00:00
Niels Dossche
d03025bf59 Fix GH-10251: Assertion `(flag & (1<<3)) == 0' failed.
zend_get_property_guard previously assumed that at least "str" has a
pre-computed hash. This is not always the case, for example when a
string is created by bitwise operations, its hash is not set. Instead of
forcing a computation of the hashes, drop the hash comparison.

Closes GH-10254

Co-authored-by: Changochen <changochen1@gmail.com>

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-08 16:09:59 +00:00
Max Kellermann
d48c5372ab Zend/zend_object_handlers: make several pointers const 2023-01-04 12:59:16 +00:00
Ilija Tovilo
4842edeae4
Improve magic __get and property type inconsistency error message
Fixes GH-9388
Closes GH-9436
2022-09-08 11:07:29 +02:00
Ilija Tovilo
40908b10fc
Merge branch 'PHP-8.1'
* PHP-8.1:
  Disallow assigning reference to  unset readonly property
2022-07-01 12:20:32 +02:00
Ilija Tovilo
110573726b
Disallow assigning reference to unset readonly property
Closes GH-7942
Closes GH-8188
2022-07-01 12:16:32 +02:00
Ilija Tovilo
3b92a96610
Convert return type of various object handlers from int to zend_result (#8755) 2022-06-26 01:00:19 +02:00
Bob Weinand
34208bfd81 Merge branch 'PHP-8.1' 2022-06-09 13:30:57 +02:00
Nicolas Grekas
96e3a9d316 Fix RC=1 references of declared properties when casting objects to arrays
Fixes GH-8655.
Closes GH-8737.
2022-06-09 13:28:12 +02:00
Ilija Tovilo
120b4f7ae6
Remove code duplication in zend_std_compare_objects (#8710) 2022-06-07 18:07:26 +02:00
Dmitry Stogov
5ca2dd3d16 Fixed assertion after clobbering object by user error handler, because
of creation dynamic property deprecation warning.

Fixes oss-fuzz #44932
2022-02-28 16:37:17 +03:00
Dmitry Stogov
f1ae13509f Fix memory leak
Fixes oss-fuzz #43988
2022-01-28 12:38:38 +03:00
Dmitry Stogov
5d6bc25063 Reset Bucket->key of deleted HastTable elemets to NULL.
This allows elimination of some Z_ISUNDEF(Bucket->val) checks.
2021-12-22 12:54:32 +03:00
Tyson Andre
024d5f4b63 Cache method overrides of ArrayAccess in zend_class_entry
Previously, code such as subclasses of SplFixedArray would check for method
overrides when instantiating the objects.

This optimization was mentioned as a followup to GH-6552
2021-12-04 11:35:38 -05:00
Nikita Popov
f0dd79a7e4 Optimize ArrayAccess method lookup
While these currently aren't cached in the class entry, we can
at least save us a lowercasing and hash calculation of the method
name.
2021-11-28 13:06:17 +01:00
Nikita Popov
902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00
Remi Collet
bc9d604430
Merge branch 'PHP-8.1'
* PHP-8.1:
  fix [-Wstrict-prototypes] buid warnings
2021-11-24 14:55:30 +01:00
Remi Collet
ef2fd0e5b5
fix [-Wstrict-prototypes] buid warnings 2021-11-24 14:55:11 +01:00
Dmitry Stogov
ddaf64b56c Avoid non-immutable map_ptr indirection 2021-10-14 12:16:18 +03:00
Dmitry Stogov
f81f874408 zend_std_get_static_method() should return NULL in case of exception thrown from user error handler 2021-09-28 10:32:54 +03:00
Nikita Popov
4796183958 Add missing scope check for readonly prop initialization
If the initializing assignment is an array append we will go through
the UNDEF codepath of get_property_ptr_ptr, which did not verify
that the initialization scope is valid.
2021-09-17 11:20:29 +02:00
Nikita Popov
3eb97a4566 Always use separate static_members_table
When running without opcache, static_members_table is shared with
default_static_members_table. This is visible in reflection output,
because ReflectionProperty::getDefaultValue() will return the
current value, rather than the default value.

Address this by never sharing the table, which matches the behavior
we already see under opcache.

Fixes bug #80821.

Closes GH-7299.
2021-07-23 09:29:32 +02:00
Levi Morrison
ae8647d9d3
Remove leading underscore for _zend_hash_find_known_hash (#7260)
Convert zend_hash_find_ex(..., 1) to zend_hash_find_known_hash(...)
Convert zend_hash_find_ex(..., 0) to zend_hash_find(...)

Also add serializable changes to UPGRADING.INTERNALS summary
2021-07-20 17:07:17 -06:00
Nikita Popov
c50f4dece0 Fix typo in comment
[ci skip]
2021-07-20 12:44:05 +02:00
Nikita Popov
6780aaa532 Implement readonly properties
Add support for readonly properties, for which only a single
initializing assignment from the declaring scope is allowed.

RFC: https://wiki.php.net/rfc/readonly_properties_v2

Closes GH-7089.
2021-07-20 12:05:46 +02:00
Nikita Popov
59a5f89f11 Merge branch 'PHP-8.0'
* PHP-8.0:
  Undef slot before destroying in unset_property
2021-07-15 09:32:55 +02:00
Nikita Popov
567e53ea58 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Undef slot before destroying in unset_property
2021-07-15 09:32:26 +02:00
Nikita Popov
ebd3a21002 Undef slot before destroying in unset_property
We need to make sure that destructors can't access the partially
destroyed property. Do the same we do in HTs.

Fixes oss-fuzz #36205.
2021-07-15 09:31:19 +02:00
Nikita Popov
5f8ed7765a Fix GC of object properties HT
We partially fixed this in bug #78379, but still don't handle
the case where the properties array is marked as grey first,
which causes a delref to not be performed later.

Fix this by treating the object properties HT the same way as
other refcounted values, including addrefs/delrefs. The object
dtor code already handles properties HT with NULL GC type, so
out of order destruction should not be a problem.

Fixes oss-fuzz #36023.
2021-07-12 11:30:20 +02:00
Nikita Popov
a80360dbed Deprecate direct access to static trait members
Static trait members may only be accessed through a class in which
the trait is used, not directly on the trait.

A complication here is that we should not store static
methods/properties for which a deprecation is triggered in a
cache slot. As the check for this is simple and cheap, I'm handling
this in the cache slot population code in the VM. The alternative
would be to pass the cache slot down into the fetching code.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-09 14:12:28 +02:00
Nikita Popov
cdbe39b16a Remove unnecessary property name unmangling
The property name isn't mangled in this context. Unmangling would
only be necessary if we used the name stored in the property_info.
2021-07-09 12:34:35 +02:00