We have problem with skipAttributes method, which behaves differently than expected.
We have an entity that has a database view as its source, lets call it ViewProduct, and it inherits from another Product entity that has a database table as its source. The database view entity ViewProduct contains more attributes like a reference to the Company entity and the column map definition is joined from both tables.
If we go through the ViewProduct entity and load the related Company entity via ORM, everything works as it should.
However, if the skipAttributes method is called in the Product entity in the initialize method, then by calling parent::initialize in the ViewProduct entity, this call is triggered even when I load the ViewProduct entity from database and this is where the problem occurs, because the related entity Company is always null.
If the skipAttributes method is not called, then Company entity is fetched as it should. This problem occurs in Phalcon version 5. In Phalcon 3 this works without any problems.
Steps to reproduce the behavior:
Here is a github link to an example application: https://github.com/slechtic/phalcon5_skip_attributes/tree/main
Details
- Phalcon version: 5.6.1
- PHP Version: 8.2.15
- Operating System: Debian 12
- Installation type: Compiling from source
- Zephir version (if any): 0.18.0
- Server: Apache
- Other related info: PostgreSQL 14
We have problem with
skipAttributesmethod, which behaves differently than expected.We have an entity that has a database view as its source, lets call it
ViewProduct, and it inherits from anotherProductentity that has a database table as its source. The database view entityViewProductcontains more attributes like a reference to theCompanyentity and the column map definition is joined from both tables.If we go through the
ViewProductentity and load the relatedCompanyentity via ORM, everything works as it should.However, if the
skipAttributesmethod is called in theProductentity in theinitializemethod, then by callingparent::initializein theViewProductentity, this call is triggered even when I load theViewProductentity from database and this is where the problem occurs, because the related entityCompanyis always null.If the
skipAttributesmethod is not called, thenCompanyentity is fetched as it should. This problem occurs in Phalcon version 5. In Phalcon 3 this works without any problems.Steps to reproduce the behavior:
Here is a github link to an example application: https://github.com/slechtic/phalcon5_skip_attributes/tree/main
Details