User tests: Successful: Unsuccessful:
Pull Request for Issue #45011.
Go to Content > Articles in Joomla Administrator.
Alias Already Contains a Number (Single Suffix)
Basic Case (No Number in Alias)
The alias increment logic was inconsistent.
Some aliases were incorrectly modified or failed to follow a structured pattern when saving copies of articles.
Aliases are incremented correctly and consistently when saving a copy.
The system ensures that numeric suffixes are handled logically without overriding existing aliases.
The original alias format remains intact, with structured numbering applied when needed.
This simple video shows the solution
https://github.com/user-attachments/assets/4bcceb2d-f34f-4451-abe9-dbb92212e9e6
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
PR-5.2-dev
|
Hi @brianteeman
thanks for your response
I can't see the "save as copy" button, as you see my screen I can only see "save", "save & close", "save to menu", and "save & new"
I'm using version 5.2-dev if this would show changes, so I can reproduce the correct issue
Hey, I do believe this will not truly solve the mentioned issue, as this originates from the Joomla framework (as far as I can tell). See issue discussion.
you only get save as copy AFTER you have saved it for the first time
@brianteeman yes great now I can see it, yes I had reproduced the issue
I'll try to solve it now, thank you for your response and for highlighting this.
@Galcedion thanks for highlighting this, I'll see it
The AdminModel has similar logic in generateNewTitle for copied items. Wouldn't it make sense to have this there as well?
@brianteeman I have changed the logic, I'll appreciate your review again
Hi @reem-atalah, I have just tested this and for me a part has improved (the one with the year in numeric) but not for a simpler case...
CASE 1: (simple)
Title of Article: Typography Alias: typography ----> hit Save and copy
Title of Article: Typography (2) Alias: typography-2 ----> hit Save and copy
Title of Article: Typography (3) Alias: typography-2-2 ----> hit Save and copy
Title of Article: Typography (4) Alias: typography-2-3 ----> hit Save and copy
Title of Article: Typography (5) Alias: typography-2-4 ----> hit Save and copy
CASE 2: (more complex - year in numeric)
Title of Article: Typography 2024 Alias: typography-2024 ----> hit Save and copy
Title of Article: Typography 2024 (2) Alias: typography-2024-2 ----> hit Save and copy
Title of Article: Typography 2024 (3) Alias: typography-2024-3 ----> hit Save and copy
Title of Article: Typography 2024 (4) Alias: typography-2024-4 ----> hit Save and copy
FOR ME (and I am not saying that I am correct) the CASE 1 is not logical compared to CASE 2...
Cheers,
Emmanuel.
As per search (https://github.com/search?q=repo%3Ajoomla%2Fjoomla-cms+StringHelper%3A%3Aincrement+dash&type=code) there are currently 8 instances of StringHelper::increment
with "dash". Instead of fixing only one instance this should be approached globally in StringHelper.
I haven't run your code, but the regex will lead to multi-increment (title-2-2) as @exlemor just pointed out.
Hmmm, I think I was thinking of one certain logic, which the error is pointing to.
Then @Galcedion you suggest that it's better to be solved in the StringHelper::increment to have a generic logic for simpler and complex cases
@reem-atalah yes, updating StringHelper::increment
would be ideal as the change affects the entirety of Joomla at once instead of individually removing said function and replacing it with local code.
As stated in the original issue:
I do believe the code is working as intended. There is no reasonable way to differentiate between e.g. years and incremental numbers (1 can be a year, too).
What is an increment and what a deliberate title of the user? The title "product-2025" can be the incremented 2025th "product" title (and not the year), "version-3" can be version 3 of something (and not the increment). I don't think this is something that can be solved with 100% precision without adjusting the formatting, e.g. introducing a different separator for incrementing within the alias (as of now Joomla uses "-" for whitespaces as well as increments).
Yes I got you, thanks for all the suggestions, I'll think about, how to make the least changes to give the correct logic.
I think yes we can use another separation for the incrementing, other than versioning or year that use hyphen
@Galcedion you are on the correct path but remember what the alias is used for (part of the url) so if you are going to introduce a different separator than the "-" it must still be url friendly
@brianteeman thanks for the highlighting, I will consider it.
Category | Libraries | ⇒ | Libraries Unit Tests |
Labels |
Added:
Unit/System Tests
|
Title |
|
I would like to add that this is most likely a breaking change in the sense that the previous behavior for article alias increments is changed. New increments of previous increments will have a different alias:
initial alias: examplearticle
increment via old system: examplearticle-2
additional increment via new system: examplearticle-2_2
(not tested but this is what I get from reading the code)
@Galcedion Hmm, logically yes there would be some aliases with dash versioning and others with underscores.
@Galcedion I can think of another solution that wouldn't have a break change in the customer experience, but it would still need change in joomla/string
I'll put my old logic(with some changes) inside the StringHelper::increment, also this won't have changes in stringURLSafe
Category | Libraries Unit Tests | ⇒ | Administration com_content Libraries |
Closing as I don't have another proposal for this issue yet
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-03-16 22:46:18 |
Closed_By | ⇒ | reem-atalah | |
Labels |
Removed:
Unit/System Tests
|
I am unable to replicate the reported error from the test instructions.
Before this PR if I create an article with a title Article and save as copy then the alias is always incremented correctly
I am unable to do anything to replicate the error shown in your screenshot.
More importantly the error that you describe is NOT the error that has been reported in #45011
The reported error is that when the title ends with a number then the number is incremented incorrectly
august-2024 should be incremented to august-2024-2 but it is incremented to august-2025 which is the bug