eZ Community » Forums » eZ Publish 5 Platform » [EZ 2014.07] - Object deleted /...
expandshrink

[EZ 2014.07] - Object deleted / relation object problem

[EZ 2014.07] - Object deleted / relation object problem

Monday 27 October 2014 11:09:03 am - 4 replies

Hi everyone,

We have a problem when we delete an object "A" (in PHP or in back office) which already exists in a relation object "B" : the id of the object "A" still exists in the database in the relation object "B".

So, when we try to manipulate objects and nodes in PHP with the repository of eZ Publish, we obtain an error because the id exists in the relation objet, but the object is deleted from the database :

 Uncaught PHP Exception eZ\Publish\Core\Base\Exceptions\NotFoundException: "Could not find 'Content' with identifier...

Do we have to put always a "try/catch" where we try to load a relation object ?

Or is it a bug in ez 5 ?

 

Tkx for your help

Modified on Monday 27 October 2014 11:15:54 am by Clem PERISCOPE

Monday 27 October 2014 12:15:29 pm

 

Do we have to put always a "try/catch" where we try to load a relation object ?

 

 

Yes, you should try/catch every call to loadContent/loadLocation. If you don't, you run the risk of a white screen of death on your live site which can be very hard to fix.

It's a good idea to log a message for each exception to help you to trace the cause.

As for your particular issue for relation(s), what code did you use to delete the object? All related links should be cleared from the ezcontentobject_link table when you delete the object.

Monday 27 October 2014 12:35:27 pm

Thanks for your help.

To delete an object, we just use the "deleteContent" method of the "ContentService" ez publish repository. It does the same as when we delete an object in the back office. The id of the relation object is not cleared (table "ezcontentobject_attribute" ).

So, it is a bit strange to add a try / catch for all "loadContent/loadLocation" calls... Do you know why the id of the object is not deleted int the relation object (table "ezcontentobject_attribute" ?

Modified on Monday 27 October 2014 12:35:51 pm by Clem PERISCOPE

Monday 27 October 2014 12:55:09 pm

Ahh yes, I see. The <relation-item> tag is not removed from the attribute xml. Might want to log that one in Jira, could be a bug!

Monday 27 October 2014 4:02:13 pm

Sounds a lot like this issue: https://jira.ez.no/browse/EZP-23523

While try/catch, although cumbersome, will work for many cases, that doesn't solve the problem where the display of a rich text field will crash the page.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from