在开发过程中,后台出现如图示错误
1 exception(s): Exception #0 (Exception): Notice: Undefined index: id in F:\www\www.magento2.com\vendor\magento\module-config\Model\Config\Structure\Element\Iterator.php on line 63 Exception #0 (Exception): Notice: Undefined index: id in F:\www\www.magento2.com\vendor\magento\module-config\Model\Config\Structure\Element\Iterator.php on line 63 <pre>#1 Magento\Config\Model\Config\Structure\Element\Iterator->setElements() called at [vendor\magento\module-config\Model\Config\Structure.php:146] #2 Magento\Config\Model\Config\Structure->getTabs() called at [generated\code\Magento\Config\Model\Config\Structure\Interceptor.php:23] #3 Magento\Config\Model\Config\Structure\Interceptor->getTabs() called at [vendor\magento\module-config\Model\Config\Structure.php:209] #4 Magento\Config\Model\Config\Structure->getFirstSection() called at [generated\code\Magento\Config\Model\Config\Structure\Interceptor.php:59] #5 Magento\Config\Model\Config\Structure\Interceptor->getFirstSection() called at [vendor\magento\module-config\Controller\Adminhtml\System\AbstractConfig.php:63] #6 Magento\Config\Controller\Adminhtml\System\AbstractConfig->dispatch() called at [vendor\magento\framework\Interception\Interceptor.php:58] #7 Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->___callParent() called at [vendor\magento\framework\Interception\Interceptor.php:138] #8 Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor\magento\module-backend\App\Action\Plugin\Authentication.php:143] #9 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor\magento\framework\Interception\Interceptor.php:135] #10 Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor\magento\framework\Interception\Interceptor.php:153] #11 Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->___callPlugins() called at [generated\code\Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor.php:32] #12 Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->dispatch() called at [vendor\magento\framework\App\FrontController.php:186] #13 Magento\Framework\App\FrontController->processRequest() called at [vendor\magento\framework\App\FrontController.php:118] #14 Magento\Framework\App\FrontController->dispatch() called at [vendor\magento\framework\Interception\Interceptor.php:58] #15 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor\magento\framework\Interception\Interceptor.php:138] #16 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor\magento\framework\Interception\Interceptor.php:153] #17 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated\code\Magento\Framework\App\FrontController\Interceptor.php:23] #18 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor\magento\framework\App\Http.php:116] #19 Magento\Framework\App\Http->launch() called at [generated\code\Magento\Framework\App\Http\Interceptor.php:23] #20 Magento\Framework\App\Http\Interceptor->launch() called at [vendor\magento\framework\App\Bootstrap.php:263] #21 Magento\Framework\App\Bootstrap->run() called at [pub\index.php:28] </pre>
没有具体的日志可供分析到具体的文件出错位置,没从下手的情况下,只需要
修改文件
\vendor\magento\module-config\Model\Config\Structure\Element\Iterator.php
付费内容限时免费中...
下的文件大约第55行内容从
1 2 3 4 5 6 7 8 | public function setElements( array $elements , $scope ) { $this ->_elements = $elements ; $this ->_scope = $scope ; if ( count ( $elements )) { $lastElement = end ( $elements ); $this ->_lastId = $lastElement [ 'id' ]; } } |
到
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public function setElements( array $elements , $scope ) { $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/config_debug.log' ); $logger = new \Zend\Log\Logger(); $logger ->addWriter( $writer ); $this ->_elements = $elements ; $this ->_scope = $scope ; if ( count ( $elements )) { $lastElement = end ( $elements ); // Log last Element $logger ->info( $lastElement ); $this ->_lastId = $lastElement [ 'id' ]; } } |
那么这里再报错的话,会提示具体的文件位置