Project

General

Profile

Actions

Bug #100934

open

Typolink soft reference parsers does not consider links to currrent page

Added by Sybille Peters over 1 year ago. Updated about 1 year ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2023-05-31
Due date:
% Done:

0%

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

Description

... if format t3://page?uid=current is used.

This manifests itself in

  1. links to current page with wrong anchor are not reported as broken in linkvalidator, see #100933
  2. no reference index entries are created for links to current page (this is described below)
  3. ...?

no reference index entries are created for links to current page

Reproduce

  1. create several links (see below) as page links, to current page, with anchor
  2. update the reference index
  3. check the database entries in the reference index

Expected result

The result should be the same whether t3://page?uid=current or t3://page?uid=<current page id> are used.

Actual result

The result is not the same:

No reference index entries are created for the links to current page (of format t3://page?uid=current or t3://page?uid=current#<anchor>). You can search for them by using the CE id, e.g.

select tablename,recuid,field,softref_key,softref_id,ref_table,ref_uid,ref_string from sys_refindex where tablename='tt_content' and (recuid=36 or recuid=37);

2 reference index entries are created for this link with target URL:

t3://page?uid=209#38
select tablename,recuid,field,softref_key,softref_id,ref_table,ref_uid,ref_string from sys_refindex where tablename='tt_content' and (recuid=38);
+------------+--------+----------+--------------+------------------------------------+------------+---------+------------+
| tablename  | recuid | field    | softref_key  | softref_id                         | ref_table  | ref_uid | ref_string |
+------------+--------+----------+--------------+------------------------------------+------------+---------+------------+
| tt_content |     38 | bodytext | typolink_tag | 1                                  | pages      |     209 |            |
| tt_content |     38 | bodytext | typolink_tag | d5747c9ecb74651c68d8215ed0c095ac:1 | tt_content |      38 |            |
+------------+--------+----------+--------------+------------------------------------+------------+---------+------------+

No reference index entries are created for this link with target URL:

t3://page?uid=current#38

No reference index entries are created for this link with target URL:

t3://page?uid=current

Source code

This seems to be due to TypolinkTagSoftReferenceParser::parse not considering links with the format t3://page?uid=current#99999999. The parser does not return the t3://page?uid=current links.

This also concerns TypolinkSoftReferenceParser.

code:

} elseif ($linkDetails['type'] === LinkService::TYPE_PAGE && preg_match('/page\?uid=(\d+)#?(\d+)?/', $matches[1], $pageAndAnchorMatches)) {

Related issues 3 (1 open2 closed)

Related to TYPO3 Core - Bug #100933: Checking internal links to current page with missing anchor is not reported as broken linkUnder Review2023-05-31

Actions
Related to TYPO3 Core - Bug #100935: Have a full description of (typolink) link formatClosed2023-05-31

Actions
Related to TYPO3 Core - Bug #94562: Link field - insufficiently checked input leads to reference index errorResolved2021-07-15

Actions
Actions #1

Updated by Sybille Peters over 1 year ago

  • Related to Bug #100933: Checking internal links to current page with missing anchor is not reported as broken link added
Actions #2

Updated by Sybille Peters over 1 year ago

  • Related to Bug #100935: Have a full description of (typolink) link format added
Actions #3

Updated by Sybille Peters over 1 year ago

  • Description updated (diff)
Actions #4

Updated by Sybille Peters over 1 year ago

  • Subject changed from Softref parser TypolinkTagSoftReferenceParser does not consider links to currrent page to Softref parser Typolink soft reference parsers does not consider links to currrent page
Actions #5

Updated by Sybille Peters over 1 year ago

  • Subject changed from Softref parser Typolink soft reference parsers does not consider links to currrent page to Typolink soft reference parsers does not consider links to currrent page
Actions #6

Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

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

Actions #7

Updated by Gerrit Code Review over 1 year ago

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

Actions #8

Updated by Gerrit Code Review over 1 year ago

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

Actions #9

Updated by Gerrit Code Review over 1 year ago

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

Actions #10

Updated by Gerrit Code Review over 1 year ago

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

Actions #11

Updated by Gerrit Code Review over 1 year ago

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

Actions #12

Updated by Sybille Peters over 1 year ago

There is the problem that the page uid is currently not passed to and not known in the softref parser. However, it is necessary to properly resolve the "current" page.

Following a discussion on Slack in the coredev channel, here are some possible solutions with their caveats:

Slack:

1. Change the signature for the parse function in the softref parsers in general to pass the $row (with pid) as optional parameter:

  • caveat: that would have to be done in a none breaking way which makes it a bit more complicated.
  • caveat: we change the interface for a pretty trivial change that is only necessary for an edge case. All extension authors have to modify their softref parsers.
  • how to do in non-breaking way:

2. fetch the page uid based on the uid in the softref parser:

  • caveat: that adds additional DB queries to fetch something we (usually) already have, making it both inefficient and adding DB funcionality to a simple parse function which is not good design and also makes the unit tests not work (unless the specific case of using "current" is ommitted in the unit tests which is also not great)

3. Leave the functionality as is except do not convert the page id to int if it contains "current", meaning pass through the "current" page uid and let the calling function worry about it

  • caveat: ugly to pass either int or string as page uid, but the result currently uses an arbitrary array anyway so there is no real strict typing
  • caveat: functionality to convert "current" to page uid must be handled in each calling function?
  • advantage: it may not always be a good idea to directly convert "current" to current page uid. For example for the reference index, we may not want to add references to itself because they add no value, this solution would be very flexible. (but we can also check that based on the page id in the calling function)

4. Add additional function to add the page uid only to the softref parsers which require it

  • function must be called before parse
Actions #13

Updated by Gerrit Code Review over 1 year ago

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

Actions #14

Updated by Gerrit Code Review over 1 year ago

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

Actions #15

Updated by Gerrit Code Review over 1 year ago

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

Actions #16

Updated by Gerrit Code Review over 1 year ago

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

Actions #17

Updated by Gerrit Code Review over 1 year ago

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

Actions #18

Updated by Gerrit Code Review over 1 year ago

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

Actions #19

Updated by Gerrit Code Review over 1 year ago

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

Actions #20

Updated by Gerrit Code Review over 1 year ago

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

Actions #21

Updated by Gerrit Code Review over 1 year ago

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

Actions #22

Updated by Gerrit Code Review over 1 year ago

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

Actions #23

Updated by Gerrit Code Review over 1 year ago

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

Actions #24

Updated by Gerrit Code Review over 1 year ago

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

Actions #25

Updated by Gerrit Code Review over 1 year ago

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

Actions #26

Updated by Gerrit Code Review about 1 year ago

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

Actions #27

Updated by Gerrit Code Review about 1 year ago

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

Actions #28

Updated by Christian Kuhn 2 days ago

  • Related to Bug #94562: Link field - insufficiently checked input leads to reference index error added
Actions

Also available in: Atom PDF