Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copied pages break slug-generation of subpages #86

Open
FiveFuenf opened this issue Mar 29, 2023 · 5 comments
Open

Copied pages break slug-generation of subpages #86

FiveFuenf opened this issue Mar 29, 2023 · 5 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@FiveFuenf
Copy link

FiveFuenf commented Mar 29, 2023

I have a problem with TYPO3 11.5.25. Subpages of a freshly copied page tree will not be auto-updated anymore, if the parent page changes its slug.

Consider the following page tree:

  • Parent Page, Slug = parent-page
    • Subpage 1, Slug = parent-page/subpage-1
    • Subpage 2, Slug = parent-page/subpage-2
    • Subpage 3, Slug = parent-page/subpage-3

Copy this page tree within the TYPO3 page tree, and insert it somewhere else. The new page tree will look like this:

  • Parent Page, Slug = parent-page-1 (note the appended "-1" to preserve unique slugs)
    • Subpage 1, Slug = parent-page/subpage-1-1 (note the same, original parent page slug, but also with appended "-1")
    • Subpage 2, Slug = parent-page/subpage-2-1
    • Subpage 3, Slug = parent-page/subpage-3-1

The origin of this problem seems to originate from EXT:redirects/Classes/Service/SlugService in the updateSlug method:

if (strpos($subPageRecord['slug'], $oldSlugOfParentPage) !== 0) {
    return null;
}

Let's say the page title of the newly copied page is changed to "New Parent Page". On saving the page, the SlugService will call the updateSlug method for each subpage as well. Let's check the strpos-if-branch mentioned before in this case:

  • $subPageRecord['slug'] is parent-page/subpage-1-1.
  • $oldSlugOfParentPage is parent-page-1.
  • parent-page/subpage-1-1 is the haystack, parent-page-1 the needle.
  • strpos('parent-page/subpage-1-1', 'parent-page-1') will of course return false, as the string is not found.
  • The updateSlug method aborts, slug of subpage is not updated.

See also #35, where the exact same issue seems to have been encountered.
The problem also occurs with a TYPO3 v10.4.34 instance.
This may be a TYPO3 core/redirects problem, not specifically sluggi-related. But fixing this with sluggi would be really helpful.

My current workaround is to forcefully regenerate the slugs of a copied pagetree with https://packagist.org/packages/internetgalerie/ig-slug. Once the slugs of the copied page tree have been cleaned up, the auto-update will work again.

@wazum wazum added bug Something isn't working enhancement New feature or request labels Mar 29, 2023
@wazum
Copy link
Owner

wazum commented Apr 3, 2023

This seems to work with the new version 12.3 of TYPO3 CMS (I'm currently working on the upgrade of sluggi).
I'll take a look at it when I start with some backports …

@fgerards
Copy link

slugs are also not updated on other language-versions in connected mode (both page and subpages) in TYPO3 10/11

@wazum
Copy link
Owner

wazum commented May 11, 2023

@fgerards Can you recreate this without sluggi (the recursive and redirects stuff is now done by the Core) or is it a problem of the extension?

@fgerards
Copy link

fgerards commented May 11, 2023

@wazum : I thought the "Sync" switch which sluggi introduces forces these recursive updates ? if not, what does the sync-toggle then do internally (tx_sluggi_sync) ?

@wazum
Copy link
Owner

wazum commented May 11, 2023

@fgerards This stuff keeps the url slug segment in sync with the page title (or any other field you configured). Otherwise, you would have to think about changing the URL when changing the title every time for yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants