Skip to content

The $newTags object should clone $resource tags collection.#21

Open
bzis wants to merge 2 commits into
FabienPennequin:masterfrom
bzis:master
Open

The $newTags object should clone $resource tags collection.#21
bzis wants to merge 2 commits into
FabienPennequin:masterfrom
bzis:master

Conversation

@bzis
Copy link
Copy Markdown

@bzis bzis commented Feb 12, 2014

The $newTags object should clone $resource tags collection.
For example we have a resource with tags 'aaa' ,'bbb';
Then we want to change tags to 'bbb', 'ccc';
$newTags = $resource->getTags();
$tagsToAdd = $newTags;
Then we remove 'bbb' tag from $tagsToAdd ($tagsToAdd->removeElement($oldTag)), because we don't need to add this tag, it already exists. But oops, it was also removed from $resource and the $resource->getTags() collection becomes not actual.

bzis added 2 commits February 12, 2014 16:57
For example we have a resource with tags 'aaa' ,'bbb';
Then we want to change tags to 'bbb', 'ccc';
$newTags = $resource->getTags();
$tagsToAdd = $newTags;
Then we remove 'bbb' tag from $tagsToAdd ($tagsToAdd->removeElement($oldTag)), because we don't need to add this tag, it already exists. But oops, it is also removed from $resource and the $resource->getTags() collection is not actual.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant