Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Field clone with Reference and do not mutate model scope in Condition::toWords #865

Merged
merged 7 commits into from
Apr 29, 2021

Conversation

mvorisek
Copy link
Member

@mvorisek mvorisek commented Apr 28, 2021

fixes #867 and https://github.com/atk4/data/blob/2.4.0/src/Model/Scope/Condition.php#L356 issue as well - Scope must not mutate Model in any sense, if something is desired to be set to gather data, it must be done on clone.

BC break:

Field::reference property was removed, replaced by Field::getReference() method.

@mvorisek mvorisek force-pushed the fix_scope_must_not_mutate_model branch from 2363941 to 78debc5 Compare April 28, 2021 09:20
@georgehristov
Copy link
Collaborator

georgehristov commented Apr 28, 2021

I am looking into it but it will be a challenge.
This was a workaround for a bigger issue I see now.

@georgehristov georgehristov force-pushed the fix_scope_must_not_mutate_model branch from 3426f9e to 4bfd093 Compare April 29, 2021 05:33
@georgehristov
Copy link
Collaborator

I added a quickfix now. The issue will be resolved when #867 is closed

@mvorisek mvorisek marked this pull request as ready for review April 29, 2021 07:32
@mvorisek
Copy link
Member Author

@georgehristov thanks, I fixed the Field cloning issue #867 as well as your have proposed.

@mvorisek mvorisek changed the title More accurate scope to words with ref Fix Field clone with Reference and do not mutate model scope in Condition::toWords Apr 29, 2021
@mvorisek mvorisek added the RTM label Apr 29, 2021
public function getReference(): ?Reference
{
return $this->referenceLink !== null
? $this->getOwner()->getRef($this->referenceLink)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need to check if getOwner() is set, as Field with reference is created always with a model. If not, invoking getOwner will throw. :)

@georgehristov
Copy link
Collaborator

Now we need to modify data/uito use Field::getReference()

@mvorisek mvorisek merged commit 50c6361 into develop Apr 29, 2021
@mvorisek mvorisek deleted the fix_scope_must_not_mutate_model branch April 29, 2021 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloning Model having fields with reference
2 participants