-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fixed a bug with string setters being executed as callables #35
Conversation
@@ -180,4 +181,25 @@ public function testWithTranslation() | |||
->all(); | |||
$this->assertEquals(2, $records->count()); | |||
} | |||
|
|||
public function testDuplicateWithSetters() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new test passes even without the change you have done to the behavior, so it's not really useful 🙂.
In general when fixing a bug write a failing test first and then fix the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I'll have to revise this test.
@@ -292,7 +292,7 @@ protected function _doAction($action, EntityInterface $entity, $prop, $value = n | |||
break; | |||
|
|||
case 'set': | |||
if (is_callable($value)) { | |||
if (is_callable($value) && !is_string($value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Micro optimisation, the !is_string()
check could be done first.
thanks! |
This bug fixes an issue with the behaviour which arises if a setter is used and a string is passed which matches a PHP function name. The function is then executed as a callable and unknown side effects are created.
I have fixed this bug and also included a new test-case to cover the regression.
/cc @ogrrd