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

Checkbox for slug exclusion does not work on "Slugs updated and redirects created" Event after save #18

Open
m41r opened this issue Oct 14, 2020 · 2 comments

Comments

@m41r
Copy link

m41r commented Oct 14, 2020

How to reproduce:

  • on a page with child pages, set checkbox "exclude_slug_for_subpages".
  • press "recalculate URL Slug" button.
  • save page -> the modal box appears "Slugs updated and redirects created".

Expected behavior:

the excluded slug should not appear on any children of that page.

Actual behavior:

the slug of all children are generated as the same way as without the checkbox set.

System:

TYPO3 CMS 10.4.8
masi 1.1.0

@dmitryd
Copy link
Contributor

dmitryd commented Feb 16, 2022

I think the problem is in TYPO3. TYPO3\CMS\Redirects\Service\SlugService::updateSlug() directly manipulates the slug and completely ignores any modifiers that slug field has:

    protected function updateSlug(array $subPageRecord, string $oldSlugOfParentPage, string $newSlugOfParentPage): ?string
    {
        if (strpos($subPageRecord['slug'], $oldSlugOfParentPage) !== 0) {
            return null;
        }

        $newSlug = rtrim($newSlugOfParentPage, '/') . '/'
            . substr($subPageRecord['slug'], strlen(rtrim($oldSlugOfParentPage, '/') . '/'));
        $state = RecordStateFactory::forName('pages')
            ->fromArray($subPageRecord, $subPageRecord['pid'], $subPageRecord['uid']);
        $fieldConfig = $GLOBALS['TCA']['pages']['columns']['slug']['config'] ?? [];
        $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, 'pages', 'slug', $fieldConfig);

        if (!$slugHelper->isUniqueInSite($newSlug, $state)) {
            $newSlug = $slugHelper->buildSlugForUniqueInSite($newSlug, $state);
        }

        $this->persistNewSlug((int)$subPageRecord['uid'], $newSlug);
        return $newSlug;
    }

The right thing here would be to fix TYPO3 to call slug modifiers.

@dmitryd
Copy link
Contributor

dmitryd commented Feb 16, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants