pimcore icon indicating copy to clipboard operation
pimcore copied to clipboard

[Bug]: An entry for object_brick_store is always written for newly created child objects.

Open chm0815 opened this issue 3 years ago • 2 comments

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 avatar Aug 02 '22 15:08 chm0815

@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: image

When I delete the brick in the parent object the table is empty again. Which pimcore version are you using?

mcop1 avatar Aug 09 '22 13:08 mcop1

Thanks for the fast answer. My current pimcore version is 10.3.x-dev. I will double-check the issue on my side.

chm0815 avatar Aug 09 '22 14:08 chm0815

@chm0815 Hello, any new insights?

mcop1 avatar Aug 29 '22 06:08 mcop1

Closed for now, if you have any news on this issue, feel free to reopen. Thank you for your efforts.

mcop1 avatar Sep 12 '22 08:09 mcop1