-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
MAGETWO-81245: All arguments for mapping methods must be compatible with call_user_func_array #11503
MAGETWO-81245: All arguments for mapping methods must be compatible with call_user_func_array #11503
Conversation
@@ -124,7 +124,7 @@ public function map(CriteriaInterface $criteria) | |||
$mapperMethod = 'map' . $camelCaseKey; | |||
if (method_exists($this, $mapperMethod)) { | |||
if (!is_array($value)) { | |||
$value = [$value]; | |||
throw \Exception('Wrong type of argument, expecting array for '. $mapperMethod); |
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.
new
operator is missing here. Looks like InvalidArgumentException
is more suitable.
Besides fixing an existing unit test
There was 1 error:
1) Magento\Framework\DB\Test\Unit\AbstractMapperTest::testMap with data set #0 (array('mapMyMapperMethodOne', 'mapMyMapperMethodTwo'), array('my-test-value1', 'my-test-value2'))
Error: Call to undefined function Exception()
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/DB/AbstractMapper.php:127
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php:141
please cover this new logic with additional test method.
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.
Thanks. Will update test also in next commit.
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.
Thanks. Will update test also in next commit.
@orlangur Seems to be good now. |
@kirmorozov thanks. Since this is a significant system behavior change could you please add a test case ensuring exception is thrown in case of passing not array as a value? Please squash changes into single commit and force push to the same branch. |
Fixed test and set InvalidArgumentException for wrong cases. (cherry picked from commit b44335b)
b44335b
to
4122d76
Compare
…be compatible with call_user_func_array #11503 - fixed code style
…be compatible with call_user_func_array #11503 - fixed code style
…be compatible with call_user_func_array #11503
Making standard data structure for use in map().
Description
Making all elements of criteria arrays for use in call_user_func_array.
Throw exception if it not.
Fixed Issues (if relevant)
Contribution checklist