Lost relationships after save

Hi all,
the following problem occurs:

//add new relationship

//edit value
$bean->value1 = "val1";

//value1 saved, but relationship is lost

What is the context? Where is that running? Which module, which hook, etc.

This is part of the custom api. For the test, I use the modules created in the modulebuilder

Check that load_relationship returns true.

yes, load_relationship returns true and add returns true

I think the bean contains links to the previous link and when saved they overwrite the new links. Is there any way to update the links in the current bean or not touch the links at all when saving?

give an example in more detail

$link = BeanFactory::getBean('test_mylinks', '53bdc89e-8dbe-53ae-278a-62d656e804b9');
$bean = BeanFactory::getBean('test_mybeans', '7a95a4f6-cab3-0931-3a43-62d65d22be6e');

$bean->description = 'The bean now have relationship';


//The bean now have relationship and description

$bean = BeanFactory::getBean('test_mybeans', '7a95a4f6-cab3-0931-3a43-62d65d22be6e');


$bean->description = 'Has the link been removed?';


//No, the relationship remains, only the description has changed

Looking in the code of the save function, I found the mention of the variables


When using updating_relationships, links are updated correctly. Are they intended for these purposes or did it indirectly correct the logic?

This command doesn’t look right, you’re using $bean twice

I don’t know about those GLOBALS you mention, I don’t think they are relevant here.