Closed nikophil closed 1 week ago
I see that autorefresh is called while the entity might not be initialized yet? Did you declare the _autoRefresh property as being "skipped" when constructing the lazy object?
Hi @nicolas-grekas
I see that autorefresh is called while the entity might not be initialized yet?
hmmm indeed, maybe it would make sense to only call it if the object is initialized
Did you declare the _autoRefresh property as being "skipped" when constructing the lazy object?
I don't think :thinking: Not sure to see how to do that... Would that help in our problem? The property $_autoRefresh
is coming from IsProxy
trait which is used directly in the proxy class, I would have expected it to be initialized with its default property.
You can see here how the proxy is created.
Something which is super strange (for me, at least :sweat_smile:) is that I have plenty of deprecations which say for instance:
Creation of dynamic property Zenstruck\Foundry\Tests\Fixture\Entity\Address\StandardAddress::$_autoRefresh is deprecated
meaning $this
in the IsProxy
trait context refers to StandardAddress
and not to ZenstruckFoundryTestsFixtureEntityAddressStandardAddressProxy
class
Just follow my advice, the current use is not compliant with the lazy objects. Chose one way or the other but the current one is indeed broken ;)
Hi @nicolas-grekas
I understand our implementation is broken, but I don't see how to fix it :sweat_smile:
how could I declare the property to be skipped, please? this sounds like the simplest solution
thanks!
Check the signature of the factory method you're calling.
You mean createLazyProxy()
?
LazyProxyTrait::createLazyProxy()
does not allow to do this :thinking:
public static function createLazyProxy(\Closure $initializer, ?object $instance = null): static
only LazyProxyTrait::createLazyGhost()
does:
public static function createLazyGhost(\Closure $initializer, ?array $skippedProperties = null, ?object $instance = null): static
our proxy system does not work with
symfony/var-exporter
7.1:or
I don't understand why it fails now, because everything is fine in
7.0.8
and nothing big was release since then https://github.com/symfony/var-exporter/releasesHere is how a proxy class generated with
ProxyGenerator
looks like: