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

MAGETWO-81245: All arguments for mapping methods must be compatible with call_user_func_array #11503

Merged
merged 1 commit into from
Nov 13, 2017

Conversation

kirmorozov
Copy link
Member

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)

  1. StockItemCriteria::setProductsFilter doesn't work with array of ids #7678: StockItemCriteria::setProductsFilter doesn't work with array of ids

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@okorshenko okorshenko self-assigned this Oct 16, 2017
@okorshenko okorshenko added this to the October 2017 milestone Oct 16, 2017
@okorshenko okorshenko added develop bug report Event: MMNY17 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 16, 2017
@@ -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);
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

@magento-engcom-team magento-engcom-team changed the base branch from develop to 2.3-develop October 20, 2017 15:32
@kirmorozov
Copy link
Member Author

@orlangur Seems to be good now.

@orlangur
Copy link
Contributor

@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)
@kirmorozov kirmorozov force-pushed the MAGETWO-81245-develop branch from b44335b to 4122d76 Compare November 6, 2017 04:54
@okorshenko okorshenko merged commit 4122d76 into magento:2.3-develop Nov 13, 2017
okorshenko pushed a commit that referenced this pull request Nov 13, 2017
…be compatible with call_user_func_array #11503

 - fixed code style
okorshenko pushed a commit that referenced this pull request Nov 13, 2017
…be compatible with call_user_func_array #11503

 - fixed code style
okorshenko pushed a commit that referenced this pull request Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report bugfix Event: MMNY17 Progress: accept Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants