pimcore
pimcore copied to clipboard
[Bug]: An entry for object_brick_store is always written for newly created child objects.
Expected behavior
Data should only be written to object_brick_query table.
Actual behavior
There is always an entry in object_brick_store. This means when deleting the brick in the root article, brick data still remains in child objects.
Steps to reproduce
Imagine a class ObjWithBrick having one Input1-field and a brick field Brick1 with a brick of type Brick1.
The following code demonstrates the saving of a parent object with a brick and a child object.
$folder = Folder::getByPath("/ObjsWithBricksAndBlocks");
$key = DataObject\Service::getValidKey("main_c1", "object");
$owb = new ObjWithBrick();
$owb->setKey($key);
$owb->setParent($folder);
$owb->setPublished(true);
$owb->setInput1($key); // set some data in the root object, not relevant for the bug
$brick1 = new DataObject\Objectbrick\Data\Brick1($owb);
$brick1->setIn1("in1"); //set some data in the brick, not relevant for the bug
$owb->getBrick1()->setBrick1($brick1);
$owb->save();
$child = new ObjWithBrick();
$childKey = $key . '_1';
$child->setKey($childKey);
$child->setParent($owb);
$child->setPublished(true);
$child->setInput1($childKey);
$child->save(); // unfortunately, here data is written to object_brick_store_Brick1_objwithbrick
@chm0815 sorry, I can´t reproduce the problem. I created a new class "ObjWithBrick" with "Bodywork" brick (the one contained in the demo). After that I slightly adapted your code and used it to create the 2 objects:
$folder = Folder::getByPath("/ObjsWithBricksAndBlocks");
$key = DataObject\Service::getValidKey("main_c1", "object");
$owb = new ObjWithBrick();
$owb->setKey($key);
$owb->setParent($folder);
$owb->setPublished(true);
$owb->setInput1($key); // set some data in the root object, not relevant for the bug
$brick1 = new DataObject\Objectbrick\Data\Bodywork($owb);
$brick1->setNumberOfDoors("5"); //set some data in the brick, not relevant for the bug
$owb->getBrick1()->setBodywork($brick1);
$owb->save();
$child = new ObjWithBrick();
$childKey = $key . '_1';
$child->setKey($childKey);
$child->setParent($owb);
$child->setPublished(true);
$child->setInput1($childKey);
$child->save(); // unfortunately, here data is written to object_brick_store_Brick1_objwithbrick
Checked the object_brickt_store after that, but I can see only entry in the table:

When I delete the brick in the parent object the table is empty again. Which pimcore version are you using?
Thanks for the fast answer. My current pimcore version is 10.3.x-dev. I will double-check the issue on my side.
@chm0815 Hello, any new insights?
Closed for now, if you have any news on this issue, feel free to reopen. Thank you for your efforts.