-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Magento\Cms\Api\Data\PageSearchResultsInterface::getItems() returns wrong type #7140
Comments
Same with Notably, the ID fields are missing, so it is not even possible to create model instances from this array. |
Still present in 2.1.7. |
The issue is in the $pages = [];
/** @var Page $pageModel */
foreach ($collection as $pageModel) {
$pageData = $this->dataPageFactory->create();
$this->dataObjectHelper->populateWithArray(
$pageData,
$pageModel->getData(),
'Magento\Cms\Api\Data\PageInterface'
);
$pages[] = $this->dataObjectProcessor->buildOutputDataArray(
$pageData,
'Magento\Cms\Api\Data\PageInterface'
);
}
$searchResults->setItems($pages); It takes every PageInterface object from the collection. Then it creates a new PageInterface model and populates it with the data from the original object. Then the newly created object is converted to an array and put into the This makes no sense to me at all. Of course you can't just patch the code since others who use this broken method rely on the wrong return type. You need to write a Plugin or your own implementation of the PageRepository to fix this. The same goes for the BlockRepository. The code is just copy+paste over there. |
Hi, @redelschaap . Thanks for the feedback. Unfortunately, I could not reproduce the issue. Can you check your problem on the latest version of Magento 2? |
Hi @dmitriyprime, there indeed seems to be a fix present on the But the issue is reported on the 2.1.x branch. and the latest released version to date is 2.1.7. As @dersam confirms, the issue seems to be still present as of 2.1.7. Would you mind trying to reproduce it to 2.1.7 given the same step? |
@dmitriyprime I currently can't check this on Magento 2.2, but I just checked on 2.1.7 and on that version it is indeed still present. It definitely should be fixed in the 2.1.x branch. |
@redelschaap , thanks for the feedback. We've created internal ticket MAGETWO-70381 to address this issue. |
@redelschaap, thank you for your report. |
Doesn't this need to be backported to 2.1.x? |
@redelschaap I think the issue with backporting this to 2.1.x would be that it is a breaking change. Fixing this in a minor bugfix release of Magento would break any module that depends on it. It is probably better to have a known bug than yet another BC break. |
@marius-wieschollek I don't see any It seems that issue was moved to |
According to the documentation,
\Magento\Cms\Api\Data\PageSearchResultsInterface::getItems()
should return an array of\Magento\Cms\Api\Data\PageInterface
objects, while it currently returns an array of arrays.Preconditions
I am using Magento 2.1.
Steps to reproduce
Expected result
According to the documentation, I would expect
$pages
to be an array of\Magento\Cms\Api\Data\PageInterface
objects.Actual result
$pages
is array of data arrays:The text was updated successfully, but these errors were encountered: