Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[VarExporter] Cannot unset hooked property #59153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SherinBloemendaal opened this issue Dec 10, 2024 · 4 comments
Closed

[VarExporter] Cannot unset hooked property #59153

SherinBloemendaal opened this issue Dec 10, 2024 · 4 comments

Comments

@SherinBloemendaal
Copy link
Contributor

Symfony version(s) affected

7.2

Description

When creating a lazy proxy using the vendor/symfony/var-exporter/LazyProxyTrait.php from an object that contains a hooked property (PHP 8.4) an error is being thrown: Error: cannot unset hooked property <class::property>

The error is triggered on:
vendor/symfony/var-exporter/Internal/LazyObjectRegistry.php::73

How to reproduce

Create a zenstruck/foundry factory for an entity which contains a hooked property. Calling any method (for example ::find() or ::createOne()) will throw the error.

Possible Solution

No response

Additional Context

No response

@stof
Copy link
Member

stof commented Dec 10, 2024

@nicolas-grekas for hooked properties, should the generated code override the properties by using hooks as well to trigger initialization ?
Or should we just skip them ?

@mztrix
Copy link

mztrix commented Jan 12, 2025

Symfony version(s) affected

7.2

Description

When creating a lazy proxy using the vendor/symfony/var-exporter/LazyProxyTrait.php from an object that contains a hooked property (PHP 8.4) an error is being thrown: Error: cannot unset hooked property <class::property>

The error is triggered on: vendor/symfony/var-exporter/Internal/LazyObjectRegistry.php::73

How to reproduce

Create a zenstruck/foundry factory for an entity which contains a hooked property. Calling any method (for example ::find() or ::createOne()) will throw the error.

Possible Solution

No response

Additional Context

No response

Hello, waiting resolution, you can extend by PersistentObjectFactory instead of PersistentProxyObjectFactory

@Kinqdos
Copy link

Kinqdos commented Jan 15, 2025

Same problem here. Looking forward for a fix 👍

@linusrush
Copy link

Ran into this a few times now. Always had to refrain from using property hooks. Any fixes soon?

nicolas-grekas added a commit that referenced this issue Feb 13, 2025
…olas-grekas)

This PR was merged into the 6.4 branch.

Discussion
----------

[VarExporter] Fix lazy objects with hooked properties

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #59153
| License       | MIT

With hook proxies when needed so that lazy objects are fully compatible with non-final hooks.

Commits
-------

540253a [VarExporter] Fix lazy objects with hooked properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants