PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar reem-atalah
reem-atalah
1 Mar 2025

Pull Request for Issue #45011.

Summary of Changes

  • Improved the logic to correctly handle existing aliases that already contain numbers, ensuring new versions follow the expected pattern e.g. august-2024 --> august-2024_2 when we take a copy from the article. Changed in stringURLSafe to accept underscores (I think it is safe but not preferred to SEO,) and add underscore regex to incrementStyles then call StringHelper::increment with style 'underscore'.

Testing Instructions

Go to Content > Articles in Joomla Administrator.

  • Alias Already Contains a Number (Single Suffix)

    1. Create an article with alias "article-2024", save it.
    2. Save it as a copy.
    3. Expected result: The copied alias should be "article-2024_2", then "article-2024_3", etc.
  • Basic Case (No Number in Alias)

    1. Create an article with alias "article", save it.
    2. Save it as a copy.
    3. Expected result: The copied alias should be "article_2", then "article_3", etc.

Actual result BEFORE applying this Pull Request

The alias increment logic was inconsistent.
Some aliases were incorrectly modified or failed to follow a structured pattern when saving copies of articles.

Expected result AFTER applying this Pull Request

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

Link to documentations

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

avatar reem-atalah reem-atalah - open - 1 Mar 2025
avatar reem-atalah reem-atalah - change - 1 Mar 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 1 Mar 2025
Category Libraries
avatar reem-atalah reem-atalah - change - 1 Mar 2025
Labels Added: PR-5.2-dev
avatar brianteeman
brianteeman - comment - 1 Mar 2025

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

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

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"
image

I'm using version 5.2-dev if this would show changes, so I can reproduce the correct issue

avatar Galcedion
Galcedion - comment - 1 Mar 2025

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.

avatar brianteeman
brianteeman - comment - 1 Mar 2025

you only get save as copy AFTER you have saved it for the first time

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

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

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

@Galcedion thanks for highlighting this, I'll see it

avatar brbrbr
brbrbr - comment - 1 Mar 2025

The AdminModel has similar logic in generateNewTitle for copied items. Wouldn't it make sense to have this there as well?

avatar reem-atalah reem-atalah - change - 1 Mar 2025
The description was changed
avatar reem-atalah reem-atalah - edited - 1 Mar 2025
avatar reem-atalah
reem-atalah - comment - 1 Mar 2025

@brianteeman I have changed the logic, I'll appreciate your review again

avatar exlemor
exlemor - comment - 1 Mar 2025

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.

avatar Galcedion
Galcedion - comment - 1 Mar 2025

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.

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

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

avatar Galcedion
Galcedion - comment - 1 Mar 2025

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

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

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

avatar brianteeman
brianteeman - comment - 2 Mar 2025

@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

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

@brianteeman thanks for the highlighting, I will consider it.

avatar raj20889
raj20889 - comment - 2 Mar 2025

Screenshot 2025-03-02 074535
still the issue is not resolved.

avatar reem-atalah reem-atalah - change - 2 Mar 2025
The description was changed
avatar reem-atalah reem-atalah - edited - 2 Mar 2025
avatar joomla-cms-bot joomla-cms-bot - change - 2 Mar 2025
Category Libraries Libraries Unit Tests
avatar reem-atalah reem-atalah - change - 2 Mar 2025
Labels Added: Unit/System Tests
avatar reem-atalah reem-atalah - change - 2 Mar 2025
Title
[5.2] Increment alias if exists
[5.2] Increment alias Correction
avatar reem-atalah reem-atalah - edited - 2 Mar 2025
avatar charvimehradu
charvimehradu - comment - 3 Mar 2025

Hi all,
I have added a comment here and I would appreciate any help or suggestions to ensure this solution works as expected across various use cases.

avatar Galcedion
Galcedion - comment - 3 Mar 2025

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)

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

@Galcedion Hmm, logically yes there would be some aliases with dash versioning and others with underscores.

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

@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

avatar reem-atalah
reem-atalah - comment - 4 Mar 2025

Hi all, as my PR this can never happen, I tried using regex a lot, but I can't get it. also concerning the title as @chmst said it would have the same problem.

avatar joomla-cms-bot joomla-cms-bot - change - 4 Mar 2025
Category Libraries Unit Tests Administration com_content Libraries
avatar reem-atalah
reem-atalah - comment - 16 Mar 2025

Closing as I don't have another proposal for this issue yet

avatar reem-atalah reem-atalah - change - 16 Mar 2025
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
avatar reem-atalah reem-atalah - close - 16 Mar 2025

Add a Comment

Login with GitHub to post a comment