main.ERROR: Cron Job magento_newrelicreporting_cron has an error: Warning: Invalid argument supplied for foreach() in /var/www/html/magento/vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php on line 82. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":65273856,"emalloc_start":62755456} [] []main.CRITICAL: Warning: Invalid argument supplied for foreach() in /var/www/html/magento/vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php on line 82 {"exception":"[object] (Exception(code: 0): Warning: Invalid argument supplied for foreach() in /var/www/html/magento/vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php on line 82 at /var/www/html/magento/vendor/magento/framework/App/ErrorHandler.php:61)"} []
Hi @dharake. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@dharake do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
@magento-engcom-team I confirm this issue is being produced on a Vanilla Magento 2.3 CE instance
Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
[ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 5. Verify that the issue is reproducible on 2.2-develop branch. Details
- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x
_Next steps are available in case you are a member of Community Maintainers._
[ ] 6. Add label Issue: Confirmed once verification is complete.
[ ] 7. Make sure that automatic system confirms that report has been added to the backlog.
Hi @dharake thank you for your report, i'm not able to reproduce following steps you described, this may be related to your configuration, or some custom modules.
No modules installed, and clearly the issue is from magento/module-configurable-product. Once again, you guys just close the topic. What's the point in reporting bugs if you guys don't listen?
Will fix it myself and come back with a solution for the users that no doubt will have the same error.
@dharake i'm have run the jobs of "newrelic" about 4 hours, and have no errors so what i need else to do to replicate this issue ?
Have you created configurable products?
@dharake, yes 2 configurable product 1 created before jobs run, 1 after.
I'll get back to this with findings after further testing, but I think it's a bit premature to close the topic no? Again, Vanilla Magento, only imported product catalogue through CSV. This is the only exception I am getting, otherwise it's a very healthy deployment.
@dharake feel free to reopen issue if issue still present.
@engcom-backlog-nazar kindly reopen
So on further inspection, the issue here is that the function is returning a boolean FALSE value or a NULL value. I haven't yet pinpointed from which records this is coming from, however I have managed to find a work around to stop the Cron job from spazzing out.
In vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php @ line 82
Commment out
foreach ($this->products as $product) {
$parentIds[] = $product->getData($metadata->getLinkField());
}
Replace with:
if(is_array($this->products)){
foreach ($this->products as $product) {
$parentIds[] = $product->getData($metadata->getLinkField());
}
}
What this is doing is checking that the value is an array before returning a value. I will update when I find the culprit data. Feel free to chime in @magento-engcom-team as I know we shouldn't edit source files, but maybe this is worth investigating?
@dharake this is not good idea to check if this an array because this in all cases must be array,
we need find out why you have this issue, and replicate this in clean magento. then we be able to fix this issue. but now not clearly understand if this issue on magento side.
@engcom-backlog-nazar, @dharake FYI
I have the same issue, however, I can't say that I have the same __Preconditions__. Replicated on 2.3.1 CE.
I am also seeing same tons of warnings on Magento EE ver. 2.3.1.
For the record, we also recently upgraded to Magento EE ver. 2.3.1 and we are also seeing the exact same error in exception and cron.log. Logs full of this error.
Bit of a coincidence that we have same issue, and if I'm honest this sort of response is becoming a tired cliche. @magento-engcom-team
I'm having the same issue on 2.3.2 EE and I don't even have configurable products. The issue happens every time the cron runs, every 2 minutes.
[2019-08-16 13:18:11] report.INFO: Cron Job magento_newrelicreporting_cron is run [] []
[2019-08-16 13:18:11] report.ERROR: Cron Job magento_newrelicreporting_cron has an error: Warning: Invalid argument supplied for foreach() in /home/<user>/<project>/vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php on line 83. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":190840832,"emalloc_start":188717728} [] []
[2019-08-16 13:18:11] report.CRITICAL: Warning: Invalid argument supplied for foreach() in /home/<user>/<project>/vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php on line 83 {"exception":"[object] (Exception(code: 0): Warning: Invalid argument supplied for foreach() in /home/<user>/<project>/vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php on line 83 at /home/<user>/<project>/vendor/magento/framework/App/ErrorHandler.php:61)"} []
Being a lazy Friday I dedicated some time to this log filler.
There is a bug in the NewRelic count gathering of configurable products, and this seems to have gotten introduced when Magento added GraphQL support to allow filtering of Configurables.
It is not good idea to do a defensive check or remove the _renderFilters function in /vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.phpand allow it to fallback to AbstractDB, in order to show the correct amount of configurables is reported.
The issue is that it cannot add parent ids to in filter before load, because at that frame, $products is not available, hence the error. Removing it allows the resource model to load the configurable products, without support for 'filtering'.
To fix it we simply amended an existing di preference on Magento\NewRelicReporting\Model\Cron by commenting out $this->reportNewRelicCron->report(), as this form of statistic gathering has no real use for us at present. Originally we added this preference due to module reporting filling up reporting_system_updates table with an unreasonable amount of records which also had no real use for us.
To live fix and stop unnecessary logging, we hardcoded a zero to vendor/magento/module-new-relic-reporting/Model/Cron/ReportNewRelicCron.php:156
So on further inspection, the issue here is that the function is returning a boolean FALSE value or a NULL value. I haven't yet pinpointed from which records this is coming from, however I have managed to find a work around to stop the Cron job from spazzing out.
In vendor/magento/module-configurable-product/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php @ line 82
Commment out
foreach ($this->products as $product) { $parentIds[] = $product->getData($metadata->getLinkField()); }Replace with:
if(is_array($this->products)){ foreach ($this->products as $product) { $parentIds[] = $product->getData($metadata->getLinkField()); } }What this is doing is checking that the value is an array before returning a value. I will update when I find the culprit data. Feel free to chime in @magento-engcom-team as I know we shouldn't edit source files, but maybe this is worth investigating?
@dharake Instead of editing core directly, you should patch. Here is a good article on how its done. https://www.classyllama.com/blog/create-apply-patches-magento-2
To live fix and stop unnecessary logging, we hardcoded a zero to vendor/magento/module-new-relic-reporting/Model/Cron/ReportNewRelicCron.php:156
Leaving that piece at 0 is not enough to fix it in live. The file vendor/magento/module-new-relic-reporting/Model/Cron/ReportCounts.php also calls the same function @124 which will result in the same error.
For the record, we also recently upgraded to Magento EE ver. 2.3.1 and we are also seeing the exact same error in exception and cron.log. Logs full of this error.
Bit of a coincidence that we have same issue, and if I'm honest this sort of response is becoming a tired cliche. @magento-engcom-team
I couldn't agree more. Like I have time to reopen issues all day for Magento that take me a good 15mins to report correctly using their format in the first place. Community support is all that keeps me from banging my head against the wall 馃槧
@gpcrocker thanks for the heads up. Mine was only a dev site at the time, but will look into the link on patches, thanks. For now I just disabled the new rellic reporting module as my client won't really need it.
@engcom-backlog-nazar 5 months now, we gonna acknowledge the issue?
Most helpful comment
@engcom-backlog-nazar, @dharake FYI
I have the same issue, however, I can't say that I have the same __Preconditions__. Replicated on 2.3.1 CE.