An artilce has
tilte: August 2024
alias: august-2024
Save as copy
title: August 2024 (2)
alias: august-2025
alias should be august-2024-2
the last number is increased
Version 5.3-dev, but probably it is an old issue
Labels |
Added:
No Code Attached Yet
|
Title |
|
Labels |
Added:
bug
|
Hi, If no one is working on this, I'll now
@reem-atalah Go ahead !
Hi @chmst
When I entered Joomla 5.2 website, and tried to create an article with the same name(using save or save and exit, no save as copy button), I saw this error, then the solution is to make the article accept to be saved(as it can't be saved with same alias name), and increment the number, am I right?
Also, the title could be repeated with no error, and no increments, is this fine?
Hey, I've been digging around for a bit (still new to the Joomla codebase) and it appears that the incrementing is done with StringHelper::increment
via the framework:
https://github.com/joomla-framework/string/blob/3.x-dev/src/StringHelper.php#L55
(loaded into prod at libraries/vendor/joomla/string/src/StringHelper.php)
The alias increments appear to use the 'dash' style. So the trailing number with a preceding dash will be incremented, if available.
Furthermore, while I understand @chmst issue with incrementing the year, 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).
It would be possible to change the format of increments to another separator ("title-2024_2" instead of "title-2024-2"), but I believe this would be at least very confusing to users, as this function and behavior has been around since 1.3).
Hi @chmst When I entered Joomla 5.2 website, and tried to create an article with the same name(using save or save and exit, no save as copy button), I saw this error, then the solution is to make the article accept to be saved(as it can't be saved with same alias name), and increment the number, am I right? Also, the title could be repeated with no error, and no increments, is this fine?
Hi @reem-atalah
Seems that you got this error because there is another article with the same alias but you may didn't see it because its status is Trashed.
Try to find it and permanently delete it then try to save and copy the article.
Hi @mabdelaziz77 , thanks for your consultation, appreciated
Where can I find the Archive or Trash?
Thanks everyone for working on this issue.
@Galcedion
.. 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)...
indeed - this is a tricky one. Otherwise I would have made a PR myself ;) .
Maybe you can parse the title and see if there is a bracket at the end which contains a number?
Hi @chmst I've tried to solve this issue in the following PRs
- Joomla string: Increment Style add
Your feedback is precious to me
Hi,
I was working on this issue, and didn't notice there are already PR's for it. My approach was to modify the increment function in the StringHelper file with the same logic @chmst suggested. I would appreciate any help or suggestions to ensure this solution works as expected across various use cases. PR#53
Hi @charvimehradu,
Thanks for your contribution! Your approach to handling both title and alias formats makes sense. However, as @Hackwar pointed out, the change is causing unit test failures in Drone CI.
Here are some suggestions to debug and improve the PR:
1️⃣ Check the Drone CI logs – Identify which test cases are failing and why.
2️⃣ Run Joomla's unit tests locally before pushing updates:
composer install # Ensure dependencies are installed
./vendor/bin/phpunit # Run unit tests
I've just back to Jomla.🤠