Question

I am working with Magento 2.3.5 community edition. I am facing this issues

Element 'block', attribute 'display': The attribute 'display' is not allowed in ..

on magento frontend when I am in 'Developer' mode. If I change my mode from 'developer' to 'Production' the frontend is loading fine with out any issue. I just want to know Why this issue is showing only in developer mode. If the issue really exists then it should shown on production mode also right ? because all the files are same for developer mode and production mode. Can you Please suggest me the solution to fix this issue. Thanks in advance.

This is complete error:
1 exception(s): Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block', attribute 'display': The attribute 'display' is not allowed. Line: 105

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block', attribute 'display': The attribute 'display' is not allowed. Line: 105

#1 Magento\Framework\Config\Dom->__construct('createObject('Magento\Framewor...', array('create('Magento\Framewor...', array('xml' => ' '/home/qaepreserv...', 'validationState' => &Magento\Framework\App\Arguments\ValidationState#000000003e1c7fac00000000115e8812#)) called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56]
#4 Magento\Framework\ObjectManager\ObjectManager->create('Magento\Framewor...', array('xml' => ' '/home/qaepreserv...', 'validationState' => &Magento\Framework\App\Arguments\ValidationState#000000003e1c7fac00000000115e8812#)) called at [vendor/magento/framework/Config/DomFactory.php:43]
#5 Magento\Framework\Config\DomFactory->createDom(array('xml' => ' '/home/qaepreserv...', 'validationState' => &Magento\Framework\App\Arguments\ValidationState#000000003e1c7fac00000000115e8812#)) called at [vendor/magento/framework/View/Model/Layout/Update/Validator.php:141]
#6 Magento\Framework\View\Model\Layout\Update\Validator->isValid('_validateMergedLayout('LAYOUT_frontend_...', '\n   load(array()) called at [generated/code/Magento/Framework/View/Model/Layout/Merge/Interceptor.php:206]
#9 Magento\Framework\View\Model\Layout\Merge\Interceptor->load() called at [vendor/magento/framework/View/Layout/Builder.php:86]
#10 Magento\Framework\View\Layout\Builder->loadLayoutUpdates() called at [vendor/magento/framework/View/Layout/Builder.php:63]
#11 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Layout.php:259]
#12 Magento\Framework\View\Layout->build() called at [vendor/magento/framework/View/Layout.php:884]
#13 Magento\Framework\View\Layout->getBlock('page_content_hea...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:414]
#14 Magento\Framework\View\Layout\Interceptor->getBlock('page_content_hea...') called at [vendor/magento/module-cms/Helper/Page.php:215]
#15 Magento\Cms\Helper\Page->prepareResultPage(&Magento\Cms\Controller\Index\Index\Interceptor#000000003e1c7ce200000000115e8812#, 'home-page-v15') called at [vendor/magento/module-cms/Controller/Index/Index.php:74]
#16 Magento\Cms\Controller\Index\Index->execute(NULL) called at [generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php:24]
#17 Magento\Cms\Controller\Index\Index\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#18 Magento\Framework\App\Action\Action->dispatch(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#19 Magento\Cms\Controller\Index\Index\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#20 Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#21 Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#), array(array('designLoader', 'customerNotifica...', 'catalog_app_acti...', 'tax-app-action-d...', 'weee-app-action-...', 'storeCheck', 'contextPlugin', 'customer-app-act...'))) called at [generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php:39]
#22 Magento\Cms\Controller\Index\Index\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/App/FrontController.php:162]
#23 Magento\Framework\App\FrontController->processRequest(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#, &Magento\Cms\Controller\Index\Index\Interceptor#000000003e1c7ce200000000115e8812#) called at [vendor/magento/framework/App/FrontController.php:98]
#24 Magento\Framework\App\FrontController->dispatch(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#25 Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#26 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:99]
#27 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(&Magento\Framework\App\FrontController\Interceptor#000000003e1c7fce00000000115e8812#, &Closure#000000003e1c7fe600000000115e8812#, &Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#28 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:69]
#29 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(&Magento\Framework\App\FrontController\Interceptor#000000003e1c7fce00000000115e8812#, &Closure#000000003e1c7fe600000000115e8812#, &Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#30 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#31 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#), NULL) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#32 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000003e1c7e2200000000115e8812#) called at [vendor/magento/framework/App/Http.php:116]
#33 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#34 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#35 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000003e1c7e4c00000000115e8812#) called at [index.php:39]
Was it helpful?

Solution

It is likely one of your layout files (or 3rd party ones) has defined a block with the property display="...."

So to find this file that gives your error, you may execute the line below from a terminal:

grep -R --include="*.xml" "display=" app/.

If this does not return anything (or does not help)

grep -R --include="*.xml" "display=" .

if the above returns nothing, then you may enlarge a bit:

grep -R --include="*.xml" "display" .

OTHER TIPS

Magento handles exceptions differently depending on modes:

  • Production Mode: Does not show exceptions to the user (exceptions are written to logs only).
  • Developer Mode: Shows errors on the frontend

More details: https://devdocs.magento.com/guides/v2.3/config-guide/bootstrap/magento-modes.html

Update: Schema validation is performed in \Magento\Framework\Config\Dom:

   /**
     * Create DOM document based on $xml parameter
     *
     * @param string $xml
     * @return \DOMDocument
     * @throws \Magento\Framework\Config\Dom\ValidationException
     */
    protected function _initDom($xml)
    {
        $dom = new \DOMDocument();
        $useErrors = libxml_use_internal_errors(true);
        $res = $dom->loadXML($xml);
        if (!$res) {
            $errors = self::getXmlErrors($this->errorFormat);
            libxml_use_internal_errors($useErrors);
            throw new \Magento\Framework\Config\Dom\ValidationException(implode("\n", $errors));
        }
        libxml_use_internal_errors($useErrors);
        if ($this->validationState->isValidationRequired() && $this->schema) {
            $errors = $this->validateDomDocument($dom, $this->schema, $this->errorFormat);
            if (count($errors)) {
                throw new \Magento\Framework\Config\Dom\ValidationException(implode("\n", $errors));
            }
        }
        return $dom;
    }

but the validation happens only in developer mode \Magento\Framework\App\Arguments\ValidationState:

   /**
     * Retrieve current validation state
     *
     * @return boolean
     */
    public function isValidationRequired()
    {
        return $this->_appMode == \Magento\Framework\App\State::MODE_DEVELOPER;
    }

Once ValidationException is thrown there is another check in \Magento\Framework\View\Model\Layout\Merge that pass the exception if Magento is in developer mode:

   /**
     * Validate merged layout
     *
     * @param string $cacheId
     * @param string $layout
     * @return $this
     * @throws \Exception
     */
    protected function _validateMergedLayout($cacheId, $layout)
    {
        $layoutStr = '<handle id="handle">' . $layout . '</handle>';

        try {
            $this->layoutValidator->isValid($layoutStr, Validator::LAYOUT_SCHEMA_MERGED, false);
        } catch (\Exception $e) {
            $messages = $this->layoutValidator->getMessages();
            //Add first message to exception
            $message = reset($messages);
            $this->logger->info(
                'Cache file with merged layout: ' . $cacheId
                . ' and handles ' . implode(', ', (array)$this->getHandles()) . ': ' . $message
            );
            if ($this->appState->getMode() === \Magento\Framework\App\State::MODE_DEVELOPER) {
                throw $e;
            }
        }

        return $this;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top