Bug #95380
closedReferenceIndex does not take LinkHandler Configuration into account
100%
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
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.
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.
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
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
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
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
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
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
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
Updated by Nikita Hovratov about 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 77e62e2a7f8465bcf4b46a82caa60edd8d9b4665.
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
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?
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
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
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
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
Updated by Henrik Ziegenhain about 3 years ago
- Status changed from Under Review to Resolved
Applied in changeset b678ba199f784f7a10aee3b7c7eb1248438b898d.