This topic contains 1 reply, has 2 voices, and was last updated by  ignat 2 years, 1 month ago.

  • Creator
  • #28514

    Konstantin Stupak

    Hi team!

    I’m developing application based on Oro BAP and I’ve faced the issue with making my entity dataaudible after installing Oro.

    The setup is as follows:

    I have an entity called Ticket and it has a property called Status.
    They are both configured to be dataaudible via Config/ConfigField annotations, as described by Oro docs.
    The field Status is of custom Doctrine type, also called Status. This custom DBAL type is correctly registered in Doctrine. Status type extends String DBAL type.

    I’ve registered custom DataAudit Field Type in my bundle class like this:
    AuditFieldTypeRegistry::addType('status', 'status');
    and ‘ve created the migration to extend oro_audit_field table with column status, which should hold the value of ticket status upon change.

    I’ve ran the migration, so I can find my newly added column in the oro_audit_field columns and also I see the old_status and new_status columns in oro_entity_config_field table for AuditField entity.

    I assume, that installation went correctly.

    Now the tricky part is that if I install my application within installation of Oro Platform – everything works fine. I can create Tickets and see the changes in Data Audit grid.

    But if I install OroCRM and then try to install my application alongside with CRM, it breaks. When I attempt to create ticket, I get following error

    Note, that I see all the columns and entity field configs in the database.

    I did some digging and debugging, resulting in following:
    Oro BAP simultaneous installation: in app/cache/%env%/oro_entities/Extend/Entity I have two files
    EX_OroDataAuditBundle_AuditField.orm.yml with following content:

    and EX_OroDataAuditBundle_AuditField.php with following code:

    Installing app after OroCRM was completely installed: I have same two files but
    EX_OroDataAuditBundle_AuditField.orm.yml is empty

    and EX_OroDataAuditBundle_AuditField.php also contains only call to a parent::__construct() method.

    And advice on what I’m doing wrong?

Viewing 1 replies (of 1 total)
  • Author
  • #28515


    Hi Konstantin,

    Please provide output of command:

    My guess is AuditFieldExtension::addType doesn’t do a good job for you, because it adds column using ExtendScope::OWNER_SYSTEM:

    ExtendScope::OWNER_SYSTEM must be used only in case when field exist in original entity class and has declared Doctrine mapping. In your case you are adding new extend fields (old_status, new_status), which are not exist in entity AuditField. To check this assumptions you can try to do the same as AuditFieldExtension::addType but with owner ExtendScope::OWNER_CUSTOM, for example:

    If this is the case then it might be a good reason to fix it in Oro to cover such cases as yours.


Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.