magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Problem when updating to Magento 2.2 #11696

Closed vodanh109 closed 7 years ago

vodanh109 commented 7 years ago

I have same problem with issue #11224. Please give to me the solution for this. My layout xml definitely have "src" attribute in each css item of "head"

Preconditions

PHP 7.0.22-0ubuntu0.16.04.1

Before: Magento verison 2.1.9 After: Magento version 2.2

Steps to reproduce

  1. replace magento version 2.1.9 to 2.2.0 in the composer.json file
  2. run composer update
  3. run bin/magento setup:upgrade
  4. run bin/magento setup:static-content:deploy -f
  5. run bin/magento setup:di:compile

Expected result

FrontEnd can work well

Actual result

FrontEnd is crashed

{"0":"Notice: Undefined index: src in \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Page\/Config\/Generator\/Head.php on line 125","1":"#0 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Page\/Config\/Generator\/Head.php(125): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined index...', '\/home\/ubuntu\/ma...', 125, Array)\n#1 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Page\/Config\/Generator\/Head.php(103): Magento\Framework\View\Page\Config\Generator\Head->processAssets(Object(Magento\Framework\View\Page\Config\Structure))\n#2 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Layout\/GeneratorPool.php(80): Magento\Framework\View\Page\Config\Generator\Head->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))\n#3 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Layout.php(344): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))\n#4 \/home\/ubuntu\/magento2\/generated\/code\/Magento\/Framework\/View\/Layout\/Interceptor.php(89): Magento\Framework\View\Layout->generateElements()\n#5 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Layout\/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()\n#6 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Page\/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()\n#7 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Layout\/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()\n#8 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Page\/Config.php(197): Magento\Framework\View\Layout\Builder->build()\n#9 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/View\/Page\/Config.php(217): Magento\Framework\View\Page\Config->build()\n#10 \/home\/ubuntu\/magento2\/app\/code\/Webkul\/Marketplace\/Controller\/Index\/Index.php(53): Magento\Framework\View\Page\Config->getTitle()\n#11 \/home\/ubuntu\/magento2\/generated\/code\/Webkul\/Marketplace\/Controller\/Index\/Index\/Interceptor.php(24): Webkul\Marketplace\Controller\Index\Index->execute()\n#12 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/App\/Action\/Action.php(107): Webkul\Marketplace\Controller\Index\Index\Interceptor->execute()\n#13 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))\n#14 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Webkul\Marketplace\Controller\Index\Index\Interceptor->callParent('dispatch', Array)\n#15 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Webkul\Marketplace\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#16 \/home\/ubuntu\/magento2\/generated\/code\/Webkul\/Marketplace\/Controller\/Index\/Index\/Interceptor.php(39): Webkul\Marketplace\Controller\Index\Index\Interceptor->callPlugins('dispatch', Array, Array)\n#17 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/App\/FrontController.php(55): Webkul\Marketplace\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#18 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))\n#19 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->callParent('dispatch', Array)\n#20 \/home\/ubuntu\/magento2\/vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#21 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#22 \/home\/ubuntu\/magento2\/app\/code\/TemplateMonster\/LayoutSwitcher\/Model\/App\/Action\/ContextPlugin.php(40): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#23 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): TemplateMonster\LayoutSwitcher\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#24 \/home\/ubuntu\/magento2\/vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#25 \/home\/ubuntu\/magento2\/app\/code\/TemplateMonster\/SiteMaintenance\/Model\/PageCache\/App\/FrontController\/BuiltinPlugin.php(30): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#26 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): TemplateMonster\SiteMaintenance\Model\PageCache\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#27 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#28 \/home\/ubuntu\/magento2\/generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->callPlugins('dispatch', Array, NULL)\n#29 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/App\/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#30 \/home\/ubuntu\/magento2\/vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\Framework\App\Http->launch()\n#31 \/home\/ubuntu\/magento2\/pub\/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))\n#32 {main}","url":"\/","script_name":"\/index.php"}

nshiff commented 7 years ago

@vodanh109 Are you in developer mode? I recommend it. It makes development a lot easier because connector files like interceptors are generated for you

magento deploy:mode:show
magento deploy:mode:set developer

rm -rf var/generation/* var/di/*
rm -rf generated/code/* generated/metadata/*

If the issue persists, maybe there is a stale module in the vendor directory.

mv vendor vendor.bak
composer install
magento setup:upgrade    # why not

Those are general troubleshooting tips just to check that you aren't defeating yourself with one of M2's many caches. If the issue persists, then it is less likely that your environment is wrong, and more likely that you found a defect in the framework.

vodanh109 commented 7 years ago

@nshiff, thanks a lot for your suggestion that help me to easily debug to find out the root cause. The problem is coming from Template Monster theme that have a PHP class to add dynamic css but without 'src' attribute into layout.

Ambertvu commented 7 years ago

@vodanh109 Where exactly did they mess up ? Having the same issue here with Templatemonster theme... Can't the exact error location yet. Or better, how did you fine the faulty TemplateMonster file ?

inluxc commented 6 years ago

Can you give us the name of the class in question so we can resolve it :D Thanks in advanced

vodanh109 commented 6 years ago

Sorry for late response. It's app/code/TemplateMonster/ThemeOptions/Observer/AddDynamicStyles.php

tidalgardens commented 6 years ago

@vodanh109 Could you please post what you changed in AddDynamicStyles.php? I am having the exact same issue and TemplateMonster (despite claiming their theme works 100% with 2.2) is giving me the run around.

pascal08 commented 6 years ago

@vodanh109 I would like to know aswell. I'm also using TemplateMonster.

Edit:

I solved it by modifying the execute() method in AddDynamicStyles.php:

    public function execute(Observer $observer)
    {
        /** @var \Magento\Framework\View\Layout $layout */
        $layout = $observer->getData('layout');

        $pageConfig = $layout->getReaderContext()->getPageConfigStructure();
        $this->_cssOptions = array_merge(['src' => $this->_getCssUrl()], $this->_cssOptions);
        $pageConfig->addAssets($this->_getCssUrl(), $this->_cssOptions);
    }
Rcreators commented 6 years ago

Hello,

Just like to add. In few template monster theme this solution needs to also apply on

app/code/TemplateMonster/NewsletterPopup/Observer/AddDynamicStyles.php

miko007 commented 6 years ago

thank you @vodanh109, you saved my ass today!