#86684"No pseudo-site found in root line of page" when copying records from one sysfolder to another
Description
**Hi,
I came across this problem when trying to copy news records in the backend.
\TYPO3\CMS\Core\DataHandling\SlugHelper->isUniqueInSite()
When copying a record, the isUniqueInSite() method is called to check if the news slug needs adjustment. This may trigger a No pseudo-site found in root line of page exception, depending on what pages are currently available in the backend.
It seems that the problem is found here:
$siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class);
$siteOfCurrentRecord = $siteMatcher->matchByPageId($pageId);
foreach ($records as $record) {
$siteOfExistingRecord = $siteMatcher->matchByPageId((int)$record['uid']);
if ($siteOfExistingRecord->getRootPageId() === $siteOfCurrentRecord->getRootPageId()) {
return false;
}
}
As far as I understand, the method $siteMatcher->matchByPageId((int)$record[‘uid’]) will work only correctly, if the current table is “pages”. When copying news records, $record[‘uid’] will contain the news’ UID, and a matchByPageId->call is made with that UID. Sometimes this may work, depending on if that page happens to exists or not.
As for now I have created a workaround for this problem:
$siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class);
$siteOfCurrentRecord = $siteMatcher->matchByPageId($pageId);
foreach ($records as $record) {
if ($this->tableName === 'pages') {
$siteOfExistingRecord = $siteMatcher->matchByPageId((int) $record['uid']);
}
else {
$siteOfExistingRecord = $siteMatcher->matchByPageId((int) $record['pid']);
}
if ($siteOfExistingRecord->getRootPageId() === $siteOfCurrentRecord->getRootPageId()) {
return false;
}
}
This seems to work, however I am not sure, if this may have unwanted side effects.
Regards,
Philipp