Warning: Invalid argument supplied for foreach() when viewing shipment

While I’m trying to view the status of a shipment.
It will shows Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in vendor/magento/module-shipping/view/adminhtml/templates/order/packaging/packed.phtml on line 12

Magento version : 2.1.4
But it also happens under 2.1.3

full error message :

1 exception(s):
Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-shipping/view/adminhtml/templates/order/packaging/packed.phtml on line 12

Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-shipping/view/adminhtml/templates/order/packaging/packed.phtml on line 12
#0 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-shipping/view/adminhtml/templates/order/packaging/packed.phtml(12): MagentoFrameworkAppErrorHandler->handler(2, 'Invalid argumen...', '/home/wwwroot/s...', 12, Array)
#1 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/home/wwwroot/s...')
#2 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/Template.php(255): MagentoFrameworkViewTemplateEnginePhp->render(Object(MagentoShippingBlockAdminhtmlOrderPackagingInterceptor), '/home/wwwroot/s...', Array)
#3 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/Template.php(279): MagentoFrameworkViewElementTemplate->fetchView('/home/wwwroot/s...')
#4 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-backend/Block/Template.php(104): MagentoFrameworkViewElementTemplate->_toHtml()
#5 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/AbstractBlock.php(659): MagentoBackendBlockTemplate->_toHtml()
#6 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(542): MagentoFrameworkViewElementAbstractBlock->toHtml()
#7 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(518): MagentoFrameworkViewLayout->_renderBlock('shipment_packed')
#8 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('shipment_packed')
#9 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/AbstractBlock.php(499): MagentoFrameworkViewLayout->renderElement('shipment_packed', true)
#10 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-shipping/view/adminhtml/templates/view/form.phtml(109): MagentoFrameworkViewElementAbstractBlock->getChildHtml('shipment_packed')
#11 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/home/wwwroot/s...')
#12 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/Template.php(255): MagentoFrameworkViewTemplateEnginePhp->render(Object(MagentoShippingBlockAdminhtmlViewForm), '/home/wwwroot/s...', Array)
#13 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/Template.php(279): MagentoFrameworkViewElementTemplate->fetchView('/home/wwwroot/s...')
#14 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-backend/Block/Template.php(104): MagentoFrameworkViewElementTemplate->_toHtml()
#15 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/AbstractBlock.php(659): MagentoBackendBlockTemplate->_toHtml()
#16 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(542): MagentoFrameworkViewElementAbstractBlock->toHtml()
#17 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(518): MagentoFrameworkViewLayout->_renderBlock('form')
#18 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('form')
#19 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/AbstractBlock.php(499): MagentoFrameworkViewLayout->renderElement('form', true)
#20 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-backend/Block/Widget/Form/Container.php(173): MagentoFrameworkViewElementAbstractBlock->getChildHtml('form')
#21 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-backend/view/adminhtml/templates/widget/form/container.phtml(15): MagentoBackendBlockWidgetFormContainer->getFormHtml()
#22 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/home/wwwroot/s...')
#23 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/Template.php(255): MagentoFrameworkViewTemplateEnginePhp->render(Object(MagentoShippingBlockAdminhtmlView), '/home/wwwroot/s...', Array)
#24 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/Template.php(279): MagentoFrameworkViewElementTemplate->fetchView('/home/wwwroot/s...')
#25 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/module-backend/Block/Template.php(104): MagentoFrameworkViewElementTemplate->_toHtml()
#26 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Element/AbstractBlock.php(659): MagentoBackendBlockTemplate->_toHtml()
#27 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(542): MagentoFrameworkViewElementAbstractBlock->toHtml()
#28 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(518): MagentoFrameworkViewLayout->_renderBlock('sales_shipment_...')
#29 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('sales_shipment_...')
#30 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('sales_shipment_...')
#31 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('content')
#32 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('content')
#33 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('content')
#34 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('main.col')
#35 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('main.col')
#36 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('main.col')
#37 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('admin.scope.col...')
#38 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('admin.scope.col...')
#39 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('admin.scope.col...')
#40 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('page.main.conta...')
#41 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('page.main.conta...')
#42 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('page.main.conta...')
#43 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('page.content')
#44 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('page.content')
#45 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('page.content')
#46 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('page.wrapper')
#47 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('page.wrapper')
#48 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('page.wrapper')
#49 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('backend.page')
#50 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('backend.page')
#51 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(569): MagentoFrameworkViewLayout->renderElement('backend.page')
#52 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(520): MagentoFrameworkViewLayout->_renderContainer('root')
#53 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(472): MagentoFrameworkViewLayout->renderNonCachedElement('root')
#54 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Layout.php(938): MagentoFrameworkViewLayout->renderElement('root')
#55 /home/wwwroot/shopkey.doyustudio.com/var/generation/Magento/Framework/View/Layout/Interceptor.php(37): MagentoFrameworkViewLayout->getOutput()
#56 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Result/Page.php(243): MagentoFrameworkViewLayoutInterceptor->getOutput()
#57 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/View/Result/Layout.php(164): MagentoFrameworkViewResultPage->render(Object(MagentoFrameworkAppResponseHttpInterceptor))
#58 /home/wwwroot/shopkey.doyustudio.com/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): MagentoFrameworkViewResultLayout->renderResult(Object(MagentoFrameworkAppResponseHttpInterceptor))
#59 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/App/Http.php(139): MagentoBackendModelViewResultPageInterceptor->renderResult(Object(MagentoFrameworkAppResponseHttpInterceptor))
#60 /home/wwwroot/shopkey.doyustudio.com/vendor/magento/framework/App/Bootstrap.php(258): MagentoFrameworkAppHttp->launch()
#61 /home/wwwroot/shopkey.doyustudio.com/pub/index.php(37): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))
#62 {main}

I tried to view the database.
And I found the difference between those shipment which failed and works.
The column “packaged” is different.
For those works, shows a:0:{}
For those fails, shows s:6:”a:0:{}”;

This error not happened for all orders.
For newer order, it works fine.
But few days passed, I’m not sure what changes.
It goes wrong.

We moved our site to another server recently.
And this error is start to happen after that.
But I don’t know what can I provide for more info.
I really have no idea about this issue 🙁
If need any extra info, could you please tell me?

Thank you, every body 🙂


Go to Source of this post
Author Of this post: 楊翔宇
Title Of post: Warning: Invalid argument supplied for foreach() when viewing shipment
Author Link: {authorlink}