Skip to content
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

Magento 2.3.1, Invalid URL key when saving category for store view #22187

Closed
KhaledJoulani opened this issue Apr 6, 2019 · 25 comments
Closed
Labels
Component: Catalog 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.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

@KhaledJoulani
Copy link

Preconditions (*)

  1. Magento 2.3.1
  2. PHP 7.2.15-0ubuntu0.18.04.2
  3. nginx version: nginx/1.14.0

Steps to reproduce (*)

You must have a second store view.

  1. Create a category with an English name and save.
  2. Select the category you just created and switch to the second store view.
  3. Un-check Use Default Value for category name and rename the category using Arabic letters and save.
  4. Now try to edit the Arabic name again and hit save, or even just save again while selecting the store view that has the Arabic category name.

Expected result (*)

  1. You saved the category.

Actual result (*)

  1. Invalid URL key

Additional information

So I checked the log file in, var/log/system.log

[2019-04-06 14:45:41] main.CRITICAL: Exception message: Invalid URL key
Trace:

#1 Magento\CatalogUrlRewrite\Observer\CategoryUrlPathAutogeneratorObserver->execute() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:72]
#2 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:60]
#3 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() called at [vendor/magento/framework/Event/Manager.php:66]
#4 Magento\Framework\Event\Manager->dispatch() called at [generated/code/Magento/Framework/Event/Manager/Proxy.php:95]
#5 Magento\Framework\Event\Manager\Proxy->dispatch() called at [vendor/magento/framework/Model/AbstractModel.php:701]
#6 Magento\Framework\Model\AbstractModel->beforeSave() called at [vendor/magento/module-catalog/Model/AbstractModel.php:383]
#7 Magento\Catalog\Model\AbstractModel->beforeSave() called at [vendor/magento/framework/EntityManager/Observer/BeforeEntitySave.php:34]
#8 Magento\Framework\EntityManager\Observer\BeforeEntitySave->execute() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:72]
#9 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:60]
#10 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() called at [vendor/magento/framework/Event/Manager.php:66]
#11 Magento\Framework\Event\Manager->dispatch() called at [generated/code/Magento/Framework/Event/Manager/Proxy.php:95]
#12 Magento\Framework\Event\Manager\Proxy->dispatch() called at [vendor/magento/framework/EntityManager/EventManager.php:52]
#13 Magento\Framework\EntityManager\EventManager->dispatchEntityEvent() called at [vendor/magento/framework/EntityManager/Operation/Update.php:106]
#14 Magento\Framework\EntityManager\Operation\Update->execute() called at [vendor/magento/framework/EntityManager/EntityManager.php:96]
#15 Magento\Framework\EntityManager\EntityManager->save() called at [vendor/magento/module-catalog/Model/ResourceModel/Category.php:1104]
#16 Magento\Catalog\Model\ResourceModel\Category->save() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#17 Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#18 Magento\Catalog\Model\ResourceModel\Category\Interceptor->Magento\Framework\Interception{closure}() called at [vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php:44]
#19 Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->addCommitCallback() called at [vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php:28]
#20 Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->aroundSave() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#21 Magento\Catalog\Model\ResourceModel\Category\Interceptor->Magento\Framework\Interception{closure}() called at [vendor/magento/framework/App/Cache/FlushCacheByTags.php:68]
#22 Magento\Framework\App\Cache\FlushCacheByTags->aroundSave() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#23 Magento\Catalog\Model\ResourceModel\Category\Interceptor->Magento\Framework\Interception{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#24 Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Model/ResourceModel/Category/Interceptor.php:52]
#25 Magento\Catalog\Model\ResourceModel\Category\Interceptor->save() called at [vendor/magento/framework/Model/AbstractModel.php:654]
#26 Magento\Framework\Model\AbstractModel->save() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#27 Magento\Catalog\Model\Category\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#28 Magento\Catalog\Model\Category\Interceptor->Magento\Framework\Interception{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#29 Magento\Catalog\Model\Category\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Model/Category/Interceptor.php:26]
#30 Magento\Catalog\Model\Category\Interceptor->save() called at [vendor/magento/module-catalog/Controller/Adminhtml/Category/Save.php:220]
#31 Magento\Catalog\Controller\Adminhtml\Category\Save->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#32 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:231]
#33 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#34 Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#35 Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->Magento\Framework\Interception{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]
#36 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#37 Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->Magento\Framework\Interception{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#38 Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Controller/Adminhtml/Category/Save/Interceptor.php:26]
#39 Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:159]
#40 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:99]
#41 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#42 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#43 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#44 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#45 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:136]
#46 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:258]
#47 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40]

[] []
[2019-04-06 14:45:41] main.INFO: Broken reference: the 'atwix_testblock' element cannot be added as child to 'head.additional', because the latter doesn't exist [] []
[2019-04-06 14:45:41] main.INFO: Broken reference: the 'notification.messages' tries to reorder itself towards 'user', but their parents are different: 'header.inner.right' and 'header' respectively. [] []

And I tried to debug the issue.
In the execute function here:
Magento\CatalogUrlRewrite\Observer\CategoryUrlPathAutogeneratorObserver->execute()
which for my Magento 2 installation is in this file:
vendor/magento/module-catalog-url-rewrite/Observer/CategoryUrlPathAutogeneratorObserver.php, Line:76.
This one: $resultUrlKey = $category->formatUrlKey($category->getOrigData('name'));
The value of $resultUrlKey is empty,
now the next line is :
$this->updateUrlKey($category, $resultUrlKey);
and in updateUrlKey() there is a check:
if (empty($urlKey)) {
throw new \Magento\Framework\Exception\LocalizedException(__('Invalid URL key'));
}.
So after all this i debugged formatUrlKey() function from line 76, found the function in:
vendor/magento/module-catalog/Model/Category.php, line:649.
In this function there is only one line:
return $this->filter->translitUrl($str);
that leads to this class:
vendor/magento/framework/Filter/TranslitUrl.php
and in there, there is this code:

class TranslitUrl extends Translit
{
    /**
     * Filter value
     *
     * @param string $string
     * @return string
     */
    public function filter($string)
    {

        $string = preg_replace('#[^0-9a-z]+#i', '-', parent::filter($string));
        $string = strtolower($string);
        $string = trim($string, '-');
        return $string;
    }
}

at this line $string = preg_replace('#[^0-9a-z]+#i', '-', parent::filter($string));
it returns " - " only.
and at this line it makes it empty :
$string = trim($string, '-');
That's all, so what pattern should I used that wont effect Arabic letters, I'm not a regex expert!.

@m2-assistant
Copy link

m2-assistant bot commented Apr 6, 2019

Hi @KhaledJoulani. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@KhaledJoulani do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Apr 6, 2019
@KhaledJoulani
Copy link
Author

@magento-engcom-team give me 2.3.1-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @KhaledJoulani. Thank you for your request. I'm working on Magento 2.3.1-develop instance for you

@KhaledJoulani
Copy link
Author

@magento-engcom-team give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @KhaledJoulani. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @KhaledJoulani, here is your Magento instance.
Admin access: https://i-22187-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@KhaledJoulani
Copy link
Author

I confirm that I was able to reproduce the issue on vanilla Magento instance following steps to reproduce.
How do i actually confirm this ? the checkbox is disabled

@KhaledJoulani KhaledJoulani reopened this Apr 6, 2019
@shikhamis11 shikhamis11 self-assigned this Apr 6, 2019
@m2-assistant
Copy link

m2-assistant bot commented Apr 6, 2019

Hi @shikhamis11. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@shikhamis11
Copy link
Member

@magento-engcom-team give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @shikhamis11. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @shikhamis11, here is your Magento instance.
Admin access: https://i-22187-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@shikhamis11 shikhamis11 added Component: Catalog Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Apr 7, 2019
@ghost ghost unassigned shikhamis11 Apr 7, 2019
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Apr 7, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @shikhamis11
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-99081 were created

Issue Available: @shikhamis11, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@shikhamis11
Copy link
Member

@magento-engcom-team give me 2.2-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @shikhamis11. Thank you for your request. I'm working on Magento 2.2-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @shikhamis11, here is your Magento instance.
Admin access: https://i-22187-2-2-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@shikhamis11 shikhamis11 added the Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release label Apr 7, 2019
@shikhamis11
Copy link
Member

it's may be related to #13689

@KhaledJoulani
Copy link
Author

Wow it's been a year on the related issue you linked, no one fixed it ?

@hostep
Copy link
Contributor

hostep commented Apr 7, 2019

And probably also related to #20879
Magento is working on adding Japanese support for url's in magento/magento2-jp#77, and this solution will probably be generalised for other languages later on I'm guessing.
Maybe @vkublytskyi can help out here?

@dmanners
Copy link
Contributor

dmanners commented Apr 8, 2019

In my view this is a duplicate of #22187 so I will close this. I know that we have a module in the Japanese localization project that is aiming at URLRewrites https://github.com/magento/magento2-jp/tree/2.3-develop/JapaneseUrlRewrite and I think this would be a good module or fixes to have in the main repository as well.

Thank you for raising this issue please feel free to track the progress in the other issue.

@dmanners dmanners closed this as completed Apr 8, 2019
@sjgdk
Copy link

sjgdk commented Jul 23, 2019

In my view this is a duplicate of #22187 so I will close this. I know that we have a module in the Japanese localization project that is aiming at URLRewrites https://github.com/magento/magento2-jp/tree/2.3-develop/JapaneseUrlRewrite and I think this would be a good module or fixes to have in the main repository as well.

Thank you for raising this issue please feel free to track the progress in the other issue.

I am sorry I couldn't get which issue you are referring to. #22187 is this issue, there is no other issue.

It's not fixed as well, so you shouldn't have closed this issue without providing a fix yet.

@knro
Copy link

knro commented Sep 16, 2019

Is there any update on this?

@hostep
Copy link
Contributor

hostep commented Sep 16, 2019

6f4f511 "might" fix this problem based on the commit message. (will be included in Magento 2.3.3, which will be out in a couple of weeks)

@Berman59
Copy link

Berman59 commented Jul 7, 2020

Was this ever fixed?

@NiklasBr
Copy link
Member

2.3.3 did not fix this, I don't understand why @dmanners closed this issue by saying that it is a duplicate of itself, he probably found some other issue and copied the incorrect number. But which issue number should it be?

@vishalthakurit
Copy link

Actually according to commit files... this is for product URL rewrite module. not for Categories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog 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.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

10 participants