Skip to content

Exception error on Module name when it has number(s) on product_options.xml - Regex issue #9985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
boostmagento opened this issue Jun 19, 2017 · 2 comments
Labels
bug report Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@boostmagento
Copy link

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

  1. Magento 2.1.7 CE - new installation, no customization
  2. PHP 7.0.19
  3. 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

  1. Create a custom module in app/code/ folder. Module name should content numbers for instance like "Organization123/Module1"
  2. Create simple etc/config.xml
  3. Create registration.php (standard approach, nothing custom)
  4. 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

  1. 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

@magento-engcom-team magento-engcom-team added 2.1.x bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 2, 2017
@magento-engcom-team
Copy link
Contributor

@boostmagento, thank you for your report.
We've created internal ticket(s) MAGETWO-80582 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@magento-engcom-team
Copy link
Contributor

@boostmagento, thank you for your report.

Unfortunately, we are archiving this ticket now as it did not get much attention from both Magento Community and Core developers for an extended period. This is done in an effort to create a quality, community-driven backlog which will allow us to allocate the required attention more easily.

Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.4-develop branch. Thank you for collaboration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants