Project

General

Profile

Actions

Bug #87454

open

Slug/URL segment - /1 is wrongly saved, when trying to set / on rootpage.

Added by Stig Nørgaard Færch over 5 years ago. Updated over 4 years ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2019-01-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If you create a sysFolder or a standard page for that matter as a container for multiple sites, then it is impossible to make the root page of these sites to have just / as slug. It always adds 1.

The reason seems to be, that when validating the slug, it also considers the slug of the parent container folder, even though the root page of the site is configured in the Sites module.
I conclude this, as if I go and manipulate the DB-record of the container folder and replace / with container in slug, then everything works as expected again.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #87884: Root page of page tree suddenly gets slug "/1"ClosedBenni Mack2019-03-11

Actions
Related to TYPO3 Core - Bug #86727: Numeric in slugs on multidomain instances.Closed2018-10-24

Actions
Actions #1

Updated by Stig Nørgaard Færch over 5 years ago

  • Category changed from DataHandler aka TCEmain to Link Handling, Site Handling & Routing
Actions #2

Updated by Guido Schmechel about 5 years ago

  • Related to Bug #87884: Root page of page tree suddenly gets slug "/1" added
Actions #3

Updated by Riccardo De Contardi about 5 years ago

  • Related to Bug #86727: Numeric in slugs on multidomain instances. added
Actions #4

Updated by Stefan Neufeind almost 5 years ago

Still an issue. Manually adjusting the slug in the database works, as expected.

Actions #5

Updated by Stefan Busemann over 4 years ago

I can confirm the issue.

Our setup:

  • default lang: de / no language slug
  • overlay: en / en as language slug

If I go the root page (in default language - pid 1) and click "recalculate URL segment", the slug changes from "/" to "/1"

Actions #6

Updated by Stefan Busemann over 4 years ago

By changing Web/typo3/sysext/core/Classes/DataHandling/SlugHelper.php

to

    public function isUniqueInSite(string $slug, RecordState $state): bool
    {
        $pageId = $state->resolveNodeAggregateIdentifier();
        $recordId = $state->getSubject()->getIdentifier();
        $languageId = $state->getContext()->getLanguageId();

        if (!MathUtility::canBeInterpretedAsInteger($pageId)) {
            // If this is a new page, we use the parent page to resolve the site
            $pageId = $state->getNode()->getIdentifier();
        }
        $pageId = (int)$pageId;

        if ($pageId < 0) {
            $pageId = $this->resolveLivePageId($recordId);
        }

        $queryBuilder = $this->createPreparedQueryBuilder();
        $this->applySlugConstraint($queryBuilder, $slug);
        $this->applyRecordConstraint($queryBuilder, $recordId);
        $this->applyLanguageConstraint($queryBuilder, $languageId);
        $this->applyWorkspaceConstraint($queryBuilder);
        $statement = $queryBuilder->execute();

        $records = $this->resolveVersionOverlays(
            $statement->fetchAll()
        );
        if (count($records) === 0) {
            return true;
        }

        // The installation contains at least ONE other record with the same slug
        // Now find out if it is the same root page ID
        $siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class);
        $siteMatcher->refresh();
        $siteOfCurrentRecord = $siteMatcher->matchByPageId($pageId);
        foreach ($records as $record) {
            try {
                $recordState = RecordStateFactory::forName($this->tableName)->fromArray($record);
                $siteOfExistingRecord = $siteMatcher->matchByPageId(
                    (int)$recordState->resolveNodeAggregateIdentifier()
                );
            } catch (SiteNotFoundException $exception) {
                // In case not site is found, the record is not
                // organized in any site or pseudo-site
                continue;
            }
            if ($siteOfExistingRecord->getRootPageId() === $siteOfCurrentRecord->getRootPageId()) {
                if ($pageId === (int)$recordState->getNode()->getIdentifier()) {
                    // if we are on the same page, we can skip it and return true
                    return true;
                } else {
                    return false;
                }
            }
        }

        // Otherwise, everything is still fine
        return true;
    }

I added this if statement:

                if ($pageId === (int)$recordState->getNode()->getIdentifier()) {
                    // if we are on the same page, we can skip it and return true
                    return true;
                } else {
                    return false;
                }
Actions

Also available in: Atom PDF