wazum / sluggi

The TYPO3 CMS slug helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copied pages break slug-generation of subpages

FiveFuenf opened this issue · comments

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.

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 …

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

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

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

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