-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
There is a regex error when you have product_options.xml BUT the name of the module contains different characters then letters. Module name needs to fit this regex: [a-zA-Z\\]. If you want to use for instance numbers then that will cause error.
Preconditions
- Magento 2.1.7 CE - new installation, no customization
- PHP 7.0.19
- Percona DB 5.7
This is an issue with a regex on module name validation in Magento and not related with PHP and MySQL version I believe.
Steps to reproduce
- Create a custom module in app/code/ folder. Module name should content numbers for instance like "Organization123/Module1"
- Create simple etc/config.xml
- Create registration.php (standard approach, nothing custom)
- Create etc/product_options.xml with an option element where the renderer's value contains the module path with numbers:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_options.xsd">
<option name="myfile" label="My File" renderer="Organization123\Module1\Block\Adminhtml\Product\Edit\Tab\Options\Type\Xfile">
<inputType name="myfile" label="My File" />
</option>
</config>
Inside the "option" tag the value of the "renderer" is a path what starts with the custom module name. This path needs to be eligible for this regex in 2.1.7
[a-zA-Z\\\\]
But because of the value has numbers in this case this will cause en Exception in the back end:
Organization123\Module1\Block\Adminhtml\Product\Edit\Tab\Options\Type\Myfile
How to get the exception
Go to admin->Product->Catalog and click on a product (any type).
URL is an edit product url like this:
www.yourdomain.com/admin/catalog/product/edit/id/xx/key/xxxxxxxxxxxx/
Expected result
- No exception error when numbers are in the custom module's name and product_options.xml is defined in etc/ folder.
Actual result
EXCEPTION
1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid XML in file /var/www/source_root/public_html/app/code/Spindle/Custoptiontype/etc/product_options.xml:
Element 'option', attribute 'renderer': [facet 'pattern'] The value 'Organization123\Module1\Block\Adminhtml\Product\Edit\Tab\Options\Type\Myfile' is not accepted by the pattern '[a-zA-Z_\\\\]+'.
Line: 3
Element 'option', attribute 'renderer': 'Organization123\Module1\Block\Adminhtml\Product\Edit\Tab\Options\Type\Myfile' is not a valid value of the atomic type 'modelName'.
Line: 3
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid XML in file /var/www/source_root/public_html/app/code/Organization123\Module1/etc/product_options.xml:
Element 'option', attribute 'renderer': [facet 'pattern'] The value 'Organization123\Module1\Block\Adminhtml\Product\Edit\Tab\Options\Type\Xfile' is not accepted by the pattern '[a-zA-Z_\\\\]+'.
Line: 3
Element 'option', attribute 'renderer': 'Organization123\Module1\Block\Adminhtml\Product\Edit\Tab\Options\Type\Myfile' is not a valid value of the atomic type 'modelName'.
Line: 3
#0 /var/www/source_root/public_html/vendor/magento/framework/Config/Reader/Filesystem.php(127): Magento\Framework\Config\Reader\Filesystem->_readFiles(Object(Magento\Framework\Config\FileIterator))
#1 /var/www/source_root/public_html/var/generation/Magento/Catalog/Model/ProductOptions/Config/Reader/Proxy.php(95): Magento\Framework\Config\Reader\Filesystem->read('global')
#2 /var/www/source_root/public_html/vendor/magento/framework/Config/Data.php(91): Magento\Catalog\Model\ProductOptions\Config\Reader\Proxy->read()
#3 /var/www/source_root/public_html/vendor/magento/framework/Config/Data.php(80): Magento\Framework\Config\Data->initData()
#4 /var/www/source_root/public_html/vendor/magento/module-catalog/Model/ProductOptions/Config.php(21): Magento\Framework\Config\Data->__construct(Object(Magento\Catalog\Model\ProductOptions\Config\Reader\Proxy), Object(Magento\Framework\App\Cache\Type\Config), 'product_options...')
#5 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Magento\Catalog\Model\ProductOptions\Config->__construct(Object(Magento\Catalog\Model\ProductOptions\Config\Reader\Proxy), Object(Magento\Framework\App\Cache\Type\Config), 'product_options...')
#6 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Catalog...', Array)
#7 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Catalog...')
#8 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Catalog...')
#9 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Catalog...', NULL, 'productOptionCo...', 'Magento\\Catalog...')
#10 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Catalog...', Array, Array)
#11 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Catalog...')
#12 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(163): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Catalog...')
#13 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(139): Magento\Framework\ObjectManager\Factory\AbstractFactory->parseArray(Array)
#14 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, NULL, NULL, 'validators', 'Magento\\Catalog...')
#15 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Catalog...', Array, Array)
#16 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Catalog...')
#17 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Catalog...')
#18 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Catalog...', NULL, 'validatorPool', 'Magento\\Catalog...')
#19 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Catalog...', Array, Array)
#20 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Catalog...')
#21 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Catalog...')
#22 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Catalog...', NULL, 'catalogProductO...', 'Magento\\Configu...')
#23 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Configu...', Array, Array)
#24 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Configu...')
#25 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Configu...')
#26 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Configu...', NULL, 'configurableTyp...', 'Magento\\Configu...')
#27 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Configu...', Array, Array)
#28 /var/www/source_root/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Configu...')
#29 /var/www/source_root/public_html/vendor/magento/framework/Interception/PluginList/PluginList.php(232): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Configu...')
#30 /var/www/source_root/public_html/vendor/magento/framework/Interception/Interceptor.php(140): Magento\Framework\Interception\PluginList\PluginList->getPlugin('Magento\\Catalog...', 'configurable')
#31 /var/www/source_root/public_html/var/generation/Magento/Catalog/Controller/Adminhtml/Product/Builder/Interceptor.php(26): Magento\Catalog\Controller\Adminhtml\Product\Builder\Interceptor->___callPlugins('build', Array, Array)
#32 /var/www/source_root/public_html/vendor/magento/module-catalog/Controller/Adminhtml/Product/Edit.php(50): Magento\Catalog\Controller\Adminhtml\Product\Builder\Interceptor->build(Object(Magento\Framework\App\Request\Http))
#33 /var/www/source_root/public_html/var/generation/Magento/Catalog/Controller/Adminhtml/Product/Edit/Interceptor.php(24): Magento\Catalog\Controller\Adminhtml\Product\Edit->execute()
#34 /var/www/source_root/public_html/vendor/magento/framework/App/Action/Action.php(102): Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->execute()
#35 /var/www/source_root/public_html/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#36 /var/www/source_root/public_html/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#37 /var/www/source_root/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->___callParent('dispatch', Array)
#38 /var/www/source_root/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor), Array, 'adminAuthentica...')
#39 /var/www/source_root/public_html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#40 /var/www/source_root/public_html/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#41 /var/www/source_root/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor), Array, 'adminMassaction...')
#42 /var/www/source_root/public_html/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#43 /var/www/source_root/public_html/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#44 /var/www/source_root/public_html/var/generation/Magento/Catalog/Controller/Adminhtml/Product/Edit/Interceptor.php(39): Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->___callPlugins('dispatch', Array, Array)
#45 /var/www/source_root/public_html/vendor/magento/framework/App/FrontController.php(55): Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#46 /var/www/source_root/public_html/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#47 /var/www/source_root/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#48 /var/www/source_root/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#49 /var/www/source_root/public_html/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#50 /var/www/source_root/public_html/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#51 /var/www/source_root/public_html/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#52 /var/www/source_root/public_html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#53 /var/www/source_root/public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#54 /var/www/source_root/public_html/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#55 {main}
Thank you,
Zsolt