Redis proxy error with inherited id #6345

Open
opened 2026-01-22 15:31:29 +01:00 by admin · 2 comments
Owner

Originally created by @andrews05 on GitHub (Nov 19, 2019).

Bug Report

Q A
BC Break yes
Version 3.0-dev

Summary

Using Redis cache causes an error when getting proxies for entities with an inherited id or inherited transient property.

Current behavior

The second time a proxy class is requested after its initial generation will cause the following error:
"Call to a member function getProperty() on null in Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php:190"

How to reproduce

  1. Configure Doctrine with Redis cache.
  2. Create entities like this:
<?php
use Doctrine\ORM\Annotation as ORM;
/** @ORM\MappedSuperclass */
class Item {
    /** @ORM\Id @ORM\Column */
    protected $id;
}
/** @ORM\Entity */
class Child extends Item {}
  1. Run doctrine orm:generate-proxies, or anything else that will get the proxy classes.
  2. Repeat step 3 a second time.

Expected behavior

No error.

Additional information

This issue does not happen on v2.7, or if using Memcached instead.
There's a comment at the line causing the error that says "TODO possible NPE".

Originally created by @andrews05 on GitHub (Nov 19, 2019). ### Bug Report | Q | A |------------ | ------ | BC Break | yes | Version | 3.0-dev #### Summary Using Redis cache causes an error when getting proxies for entities with an inherited id or inherited transient property. #### Current behavior The second time a proxy class is requested after its initial generation will cause the following error: "Call to a member function getProperty() on null in Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php:190" #### How to reproduce 1. Configure Doctrine with Redis cache. 2. Create entities like this: ``` <?php use Doctrine\ORM\Annotation as ORM; /** @ORM\MappedSuperclass */ class Item { /** @ORM\Id @ORM\Column */ protected $id; } /** @ORM\Entity */ class Child extends Item {} ``` 3. Run `doctrine orm:generate-proxies`, or anything else that will get the proxy classes. 4. Repeat step 3 a second time. #### Expected behavior No error. #### Additional information This issue does not happen on v2.7, or if using Memcached instead. There's a comment at the line causing the error that says "TODO possible NPE".
Author
Owner

@SenseException commented on GitHub (Nov 24, 2019):

The mentioned comments:
99b7d1e9d4/lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php (L170)
99b7d1e9d4/lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php (L190)

@andrews05 Does this happen because Child itself doesn't have the annotations despite that a mapped superclass is used?

@SenseException commented on GitHub (Nov 24, 2019): The mentioned comments: https://github.com/doctrine/orm/blob/99b7d1e9d4bfa6efb86f0a77b1e5522ec8e9bf9a/lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php#L170 https://github.com/doctrine/orm/blob/99b7d1e9d4bfa6efb86f0a77b1e5522ec8e9bf9a/lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php#L190 @andrews05 Does this happen because `Child` itself doesn't have the annotations despite that a mapped superclass is used?
Author
Owner

@andrews05 commented on GitHub (Nov 24, 2019):

@SenseException you mean the id annotation? I don’t think you’re allowed to re-declare a field in a subclass, doctrine will complain.
My actual use case is with JTI, where the id is necessarily inherited.

@andrews05 commented on GitHub (Nov 24, 2019): @SenseException you mean the id annotation? I don’t think you’re allowed to re-declare a field in a subclass, doctrine will complain. My actual use case is with JTI, where the id is necessarily inherited.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6345