Project

General

Profile

Actions

Bug #95380

closed

ReferenceIndex does not take LinkHandler Configuration into account

Added by Franz Kugelmann about 3 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
Start date:
2021-09-28
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When using the linkhandler to configure links to single records like explained in https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ApiOverview/LinkBrowser/Linkhandler/Index.html, the resulting entries in sys_refindex are broken. As a result the references are not show correctly and running the command cleanup:missingrelations results in an exception like

 [ Doctrine\DBAL\Exception\TableNotFoundException ]                                                          
  An exception occurred while executing 'SELECT `uid`, `pid` FROM `news` WHERE `uid` = ?' with params [587]:  

  Table 'db.news' doesn't exist

How to reproduce (in v10 and v11 - probably also v9):

Add LinkHandler configuration like

TCEMAIN.linkHandler {
    news {
        handler = TYPO3\CMS\Recordlist\LinkHandler\RecordLinkHandler
        label = News
        configuration {
            table = tx_news_domain_model_news
            storagePid = 0
            pageTreeMountPoints = 0
            hidePageTree = 0
        }
        scanAfter = page
        displayAfter = page
    }
}

Create a link in tt_content::header_link to a record (in this case News), this will result in something like
t3://record?identifier=news&uid=599

You can also just copy the above link into the header_link field. It does not matter which record is linked.
The issue is that the ReferenceIndex row is just filled with the identifier (here "news") in field sys_refindex::ref_table. But it must be the real tablename (here "tx_news_domain_model_news") given in the linkhandler configuration.
Note:
LinkHandler-Links in RTE fields do not create entries in sys_refindex, you have to create the link in field header_link to reproduce the issue

Actions #1

Updated by Nikita Hovratov about 3 years ago

The problem lies in TypolinkSoftReferenceParser:

            case LinkService::TYPE_RECORD:
                $finalTagParts['table'] = $linkData['identifier'];
                $finalTagParts['uid'] = $linkData['uid'];
                break;

The identifier is taken directly as the table.
The Page TsConfig is needed to resolve the table, but the pid context is missing at this point.

The workaround would be simply to use the table name as identifier.
A real solution could be to add the original pid to the URL.

Actions #2

Updated by Franz Kugelmann about 3 years ago

The workaround with the tablename as identifier fails if you have multiple LinkHandler configurations for the same table, ie. events and news.
What about a check before writing into sys_refindex, if the given table or keyword does even exist? If not, load the PageTS based on sys_refindex::recuid (the dataset where the link is set) - from there the pid and thus the PageTSConfig could be fetched.
If still no existing tablename could be found don't write the entry into sys_refindex.

Actions #3

Updated by Gerrit Code Review about 3 years ago

  • Status changed from New to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71340

Actions #4

Updated by Gerrit Code Review about 3 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71340

Actions #5

Updated by Gerrit Code Review about 3 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71340

Actions #6

Updated by Gerrit Code Review about 3 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71340

Actions #7

Updated by Gerrit Code Review about 3 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71340

Actions #8

Updated by Gerrit Code Review about 3 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71340

Actions #9

Updated by Gerrit Code Review about 3 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71340

Actions #10

Updated by Nikita Hovratov about 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #11

Updated by Henrik Ziegenhain about 3 years ago

Hi, thanks for taking care of this issue.
I discovered this misbehaviour this morning, too.

Currently it is only applied to "master" - which meens "v11", I think?!

Any chance to get this into v10?

Kind Regards,
Henrik

Actions #12

Updated by Henrik Ziegenhain about 3 years ago

Ahh damnit, I checked how it is working.

It changes the `ref_table` field on saving of new links and does not resolve "wrong" ref_tablename when running the missingreleations command.
That would be a breaking change for V10 - right?

Actions #13

Updated by Gerrit Code Review about 3 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72193

Actions #14

Updated by Gerrit Code Review about 3 years ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72201

Actions #15

Updated by Gerrit Code Review about 3 years ago

Patch set 2 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72193

Actions #16

Updated by Gerrit Code Review about 3 years ago

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72202

Actions #17

Updated by Henrik Ziegenhain about 3 years ago

  • Status changed from Under Review to Resolved
Actions #18

Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF