No Code Attached Yet bug
avatar chmst
chmst
25 Feb 2025

Steps to reproduce the issue

An artilce has
tilte: August 2024
alias: august-2024

Save as copy
title: August 2024 (2)
alias: august-2025

Expected result

alias should be august-2024-2

Actual result

the last number is increased

System information (as much as possible)

Version 5.3-dev, but probably it is an old issue

Additional comments

avatar chmst chmst - open - 25 Feb 2025
avatar joomla-cms-bot joomla-cms-bot - change - 25 Feb 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 25 Feb 2025
avatar chmst chmst - change - 25 Feb 2025
The description was changed
avatar chmst chmst - edited - 25 Feb 2025
avatar chmst chmst - change - 25 Feb 2025
The description was changed
avatar chmst chmst - edited - 25 Feb 2025
avatar chmst chmst - change - 25 Feb 2025
Title
Increment alias not correct
[5.2] Increment alias not correct
avatar chmst chmst - edited - 25 Feb 2025
avatar chmst chmst - change - 25 Feb 2025
The description was changed
avatar chmst chmst - edited - 25 Feb 2025
avatar chmst chmst - change - 25 Feb 2025
Labels Added: bug
avatar chmst chmst - labeled - 25 Feb 2025
avatar hoseingbh
hoseingbh - comment - 26 Feb 2025

I've just back to Jomla.🤠

avatar reem-atalah
reem-atalah - comment - 1 Mar 2025

Hi, If no one is working on this, I'll now

avatar joomdonation
joomdonation - comment - 1 Mar 2025

@reem-atalah Go ahead !

avatar reem-atalah
reem-atalah - comment - 1 Mar 2025

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?

Image

avatar Galcedion
Galcedion - comment - 1 Mar 2025

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

avatar mabdelaziz77
mabdelaziz77 - comment - 2 Mar 2025

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?

Image

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.

avatar reem-atalah
reem-atalah - comment - 2 Mar 2025

Hi @mabdelaziz77 , thanks for your consultation, appreciated
Where can I find the Archive or Trash?

avatar alikon
alikon - comment - 2 Mar 2025

click filter options and select the wanted status

Image

avatar reem-atalah
reem-atalah - comment - 2 Mar 2025

@alikon great thank you

avatar chmst
chmst - comment - 2 Mar 2025

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?

avatar reem-atalah
reem-atalah - comment - 3 Mar 2025

Hi @chmst I've tried to solve this issue in the following PRs

- Increment alias Correction

- Joomla string: Increment Style add

Your feedback is precious to me

avatar charvimehradu
charvimehradu - comment - 3 Mar 2025

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

avatar raj20889
raj20889 - comment - 3 Mar 2025

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  

Add a Comment

Login with GitHub to post a comment