[com_menus] improve alias check and generation#10756
[com_menus] improve alias check and generation#10756wilsonge merged 5 commits intojoomla:stagingfrom
Conversation
|
Pleas set the $this->type= 'url' to empty to get a date as the alias is no use for an url and it will avoid an error if the alias is used for another menu item with same parent. THis was the reason it was implemented such originally. |
|
@infograf768 maybe adding a date to a menu item alias of the external link to "save alias" is not the correct behaviour. Imagine the following scenario. i have a parent menu item with a external link menu item type. And a child with a article menu item type. In the before this patch scenario we get a SEF URL something like |
|
I have tested this item 🔴 unsuccessfully on d884169 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10756. |
|
Forget the unsuccesful test |
|
I have tested this item ✅ successfully on d884169 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10756. |
|
Note: I understand you have prepared the PR to use different strings in the future, but is it really necessary at this point? For the moment, we just want to correct the bug (with ALL). |
|
You have already tested this. The only difference is that this PR does not change the error message as there was a debate on the link with target blank. |
|
I have tested this item ✅ successfully on d884169 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10756. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10756. |
libraries/legacy/table/menu.php
Outdated
| // The alias already exists. Send an error message. | ||
| if ($errorType) | ||
| { | ||
| $message .= JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS' . ($this->menutype != $table->menutype ? '_ROOT' : '')); |
There was a problem hiding this comment.
Concatenation with undefined variable?
There was a problem hiding this comment.
undefined variable?
?
There was a problem hiding this comment.
$message was never defined before this line and this line uses .= operator.
There was a problem hiding this comment.
you're right! thanks will correct.
There was a problem hiding this comment.
corrected
|
This PR has received new commits. CC: @brianteeman, @infograf768 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10756. |
|
Why we are having checks inside Was there any specific reason? |
|
Just removed the dot from the message (shouldn't be a concatenation). |
I had that doubt also, didn't know why was like that, so reused what existed. |
|
IMO, the data should be not strongly coupled with configuration as much as possible. If we can allow same alias for different language selection, that should be true even when multilingual is off (of course by still checking the language attribute). Because we won't be able to revalidate if the settings change. And I don't think this matter is so straight forward. There must be some association check involved so as to allow alias sharing only for those items which just differ in language and not the content. E.g. - Following can be a justifiable set to share same alias: But not for the following set: I don't know what we should do about this, so thought to share here. PS: es isn't my native language 😄 |
I totally agree, but IMHO this is a very special case, is not everyday we change a site from multi-lingual to mono-lingual and vice-versa.
If we allow the same alias for two menu items in the root level in a mono-lingual site (not matter the language) we'll get the same url in the frontend for two menu items which cannot happen. @infograf768 please check this. |
I undestand. Thats why I said
Edit: |
indeed. pr is fine by solving this possible issue and i can't believe nobody saw that issue before... |
Summary of Changes
This PR makes several changes on the menu alias generate process.
Also solves some issues in the current alias generate process:
In a monolingual site (language filter plugin disabled), create a menu item with the same alias as other menu item you have in the same/other menu root but with different language.
You'll notice it will save with success but it shouldn't.
In a multilingual site (language filter plugin enabled), create a menu item with the same alias as other menu item with All language you have in the same/other menu root but in a different language.
You'll notice it will save with success but it shouldn't.
Create a menu item of System Links -> Any type
You'll notice the generate alias is the current date, not menu item title.
Testing Instructions
This needs to be tested with the proper attention.
Menu item Btomenu-item-a. It should give a error message.Menu item Ftomenu-item-a. It should give a error message.Menu item Btomenu-item-a. It should give a error message.Menu item Ftomenu-item-e. It should save fine.Menu item Etomenu-item-a. It should give a error message.Finally do a code review of the changes.
Observations
The alias cannot be duplicated in the following cases:
Monolingual Site (language filter plugin disabled)
Multilingual Site (language filter plugin enabled)
@infograf768 please check if all is working fine.