Review main Merged

47094[FEATURE] Add LinkService and "t3://" linking syntax

Benni Mack CR +2 V +2 Nightmare +2231 −305 updated 08/10/16, 10:36

Commit message

A new and unified syntax to link to pages, files, folders
within a TYPO3 instance is added. All links are prefixed
with "t3://".

This patch adds a LinkService to convert from the "old"
typolink syntax to the new syntax, and also allows to add
the new syntax to typolink syntax.

The further steps are
* Don't replace the <a> tags with <links-tags inside the RTE transformations anymore
* Make the frontend lib.parseFunc_RTE deal with <a> tags directly
* Add a migration wizard for existing content

Review

  • Code review CR +2
    • Andreas Kienast +2
    • Georg Ringer +1
    • Frank Nägler +1
  • Verified V +2
    • Andreas Kienast +2
    • Frank Nägler +1
    • TYPO3com +1 CI

Issues 1

Files 33

Show 13 more files

Review log 4956

Show 31 earlier messages
  1. Benni Mack uploaded patch set 1 03/05/16, 12:46

  2. Benni Mack uploaded patch set 2 03/05/16, 13:36

  3. Benni Mack uploaded patch set 3 03/05/16, 18:07

  4. Benni Mack uploaded patch set 4 03/05/16, 18:16

  5. Benni Mack uploaded patch set 5 03/05/16, 18:49

  6. Mathias Schreiber uploaded patch set 6 03/05/16, 21:52

  7. Benni Mack uploaded patch set 7 03/05/16, 22:40

  8. Mathias Schreiber uploaded patch set 8 03/06/16, 11:19

  9. Benni Mack wrote 03/06/16, 12:01

    Patch set 9: Commit message was updated.
  10. Benni Mack wrote 03/06/16, 12:49

    Patch set 10: Commit message was updated.
  11. Andreas Wolf commented on patch set 10 CR +1 V +1 03/06/16, 17:33

    ContentObjectRenderer.php:5870

    probably add a comment here that the fragment was named section historically
  12. Frank Nägler commented on patch set 10 03/07/16, 08:24

    how to handle custom link types, e.g. links to news or custom records?
  13. Frank Nägler commented on patch set 10 03/07/16, 11:14

    ok, will rephrase my question: What is the plan to handle custom links e.g. news? When will this be possible with the new syntax?
  14. Christian Kuhn commented on patch set 10 03/07/16, 20:37

    this needs thoughts. i'll try to put my head into this a bit over the next days and will contact benni with some details. one question that comes up in my head already is if we could maybe document the new syntax in a formal grammar like bnf. this could be very helpful to specify the blows and whistles and to validate and parse this stuff.
  15. Markus Klein commented on patch set 10 03/07/16, 20:42

    +1 lolli for a BNF. Not only for this, but maybe also for linkhandlers in general. Including the linkhandler ext into Core is still on my todo since one year or so.
  16. Helmut Hummel commented on patch set 10 CR -1 03/08/16, 08:32

    The proposed syntax is URN like[1], which is pretty smart and neat. URNs in its pure form have a BNF already: <URN> ::= "urn:" <NID> ":" <NSS> However the proposed syntax does not really follow this BNF, but as it does not start with "urn:" but with "t3:". So, a correct URN would rather be: urn:x-t3:<NSS>, where <NSS> woud be the "Resource identifier" prefixed by the "Resource handler key". There are however a few things to consider when going this path: 1. URNs have been deprecated in favor of URIs[1] to identifiy and/or locate resources 2. The NSS proposed here (for referencing pages), is self made, arbitrary, non uniform, somewhat difficult to parse and unflexible. Therefore I propose a URI syntax rather than a URN syntax to represent resources of a TYPO3 installation like that: "typolink://page?id=12&type=0&foo=bar#fragment" This URI can be parsed with parse_url() in one step, the scheme representing the "syntax namespace" (be it "t3" or "typolink" does not really matter here), the host representing the "resource handler key" and the query representing the "resource identifier" The resource identifier in such a form, can be parsed in one step as well using parse_str(). Instead of having a custom, unflexible hard to parse syntax (<id/alias>,<type>?<additionalQueryString>#fragment), we have straightforward, standard, extensible and uniform way to identifiy a resource. The handler of the type "page" can get this parsed array and iterate over the found keys pretty easily. Summary: With the proposed URI syntax, we get a bnf for free[2], have a flexible and extensible syntax that is really robust and future proof. Side note: This syntax (neither the one proposed in the patch, nor the one proposed by me) does not replace the typolink parameter syntax completely yet, as the latter allows to specify some tag values as well (target, title, class…). The complete typolink syntax should be replaced with a proper XML tag (prefereably <a> tag) where the href attribute contains the URI to the resource and other attributes can be added at will (or by configuration). [1]https://en.wikipedia.org/wiki/Uniform_Resource_Name [2]https://www.w3.org/Addressing/URL/5_URI_BNF.html
  17. Helmut Hummel commented on patch set 10 03/08/16, 09:36

    looking at https://docs.google.com/document/d/10EgY5VUxF-vo46XDFqp6JjjsUr4cxZX7ykNHVgQj37s/edit?pref=2&pli=1, there might be even more to consider. My proposed syntax could however handle that as well: "typolink://record?table=pages&id=12&type=0&foo=bar#fragment" But we could also include the path and make the host name and path be the combined resource handler identifier: "typolink://record/pages?id=12&type=0&foo=bar#fragment" $resourceHandlerIdentifier = $parsedUri['host'] . ($parsedUri['path'] ?? '') both are valid. choose at your own liking
  18. Helmut Hummel commented on patch set 10 03/08/16, 10:43

    I also have architectural remarks as well. The "LinkService" class does way too much. It does: 1. Converts legacy notations to new resource representation (array) 2. Converts UR(N/I) notation to resource representation checking for hard coded handlers 3. Implements resource handling functionality for different (hard coded) resources Downsides are: tight coupling (see number of imports), fat class with indistinct functionality, impossible to extend (closed for extension) These are 3 architectural no nos, which can easily be resolved by having dedicated classes for the following functionality: 1. Conversion from legacy resource notation to new resource notation should be a dedicated class (LegacyLinkNotationConverter) 2. Resolve resource handler from URI (ResourceHandlerResolver): 3. Resource handler classes. 3a) They should be regitered somehow (registriation can be skipped in the first run) 3b) Each resource handler is reposnsible for a single resource handler indentifier (I think we won't need a stack of handler for one identifier with priorities in the first run, but may be worth considering. Hm, maybe replace that with current URL processors) 3c) Each resoruce handler should implement an interface defining that they: 1. retrieve a public URL for the resource (not sure what else is needed)
  19. Helmut Hummel wrote 03/08/16, 10:54

    Removed the following votes: * Code-Review-1 by Helmut Hummel <helmut.hummel@typo3.org>
  20. Benni Mack commented on patch set 10 CR -2 03/08/16, 17:03

    will tackle this one with the remarks added.
  21. Frank Nägler commented on patch set 10 04/01/16, 15:16

    nice idea, here are some ideas for possible use cases (only ideas, please not discuss now if this are useful ideas ;), maybe this helps finding the "correct" syntax: ## Links in Frontend # Link to page: t3://page?id=12&type=0&foo=bar#fragment # Link to a FAL record (file or folder) t3://fal?id=1 # Link to a FAL file record t3://fal?id=1&type=file # Link to a FAL folder record t3://fal?id=1&type=folder # Link to any kind of record t3://record?table=tx_news_domain_model_news&id=1 t3://record?config=news&id=1 # Link to an email (maybe mailto: !?) t3://mail?to=foo@bar.baz&subject=foo # Link to external sources http://www.google.com https://www.google.com ## Links in Backend # Link to preview a page t3://preview?id=1 t3://preview?id=1&feuser=123 # Link to BE module t3://backend?route=/main # Link to controller/action t3://backend?controller=Foo&action=bar # Link to help t3://help?table=_MOD_web_layout&field=language_list # Search Link t3://search?term=foo # Cache Links t3://cache?clear=[all|page]&id=1
  22. Markus Klein commented on patch set 10 04/01/16, 18:24

    I'm +1 for URIs and XML compliant handling of the additional attributes. header_link for instance should hold a real <a href="t3://page..." class="ole" /> tag then.
  23. Jozef Spisiak uploaded patch set 11 04/14/16, 12:46

  24. Christian Kuhn commented on patch set 11 04/14/16, 12:47

    still wip, pushed by josef to show an intermediate state.
  25. Jozef Spisiak uploaded patch set 12 04/15/16, 18:53

  26. Jozef Spisiak commented on patch set 12 04/15/16, 18:57

    Still wip, I think I implemented now Helmuts comments in regard to the code. I will now continue with the migration wizard. Please check if I placed the new files in correct folders and if they are named properly.
  27. Christian Kuhn commented on patch set 12 04/15/16, 19:05

    ContentObjectRendererTest.php:119

    this is a bit smelly (but imho no blocker for now): it means there is some incomplete mocking in tests that fail if those lines are not added.
  28. Benni Mack uploaded patch set 13 05/19/16, 21:29

  29. Benni Mack uploaded patch set 14 05/19/16, 21:31

  30. Benni Mack commented on patch set 14 05/19/16, 21:32

    IMHO the rest of the job here is: - move LinkService to LinkHandling folder - add comments to all methods - use [] syntax instead of mixed array() and [] in new code - re-check and re-read tests - re-check and re-read code - re-check RST file - test the stuff in real life
  31. Benni Mack uploaded patch set 15 05/20/16, 21:21

  1. Benni Mack voted on patch set 14 CR 0 05/20/16, 21:25

  2. Benni Mack voted on patch set 15 CR 0 05/20/16, 21:25

  3. Georg Ringer voted on patch set 15 V +1 05/24/16, 21:38

  4. Wouter Wolters commented on patch set 15 CR -1 06/10/16, 15:08

    did a complete review now.

    FileLinkHandler.php:20

    files not folders

    FolderLinkHandler.php:34

    whitespace here

    LinkService.php:94

    @throws missing

    LinkService.php:140

    @throws missing

    UrlLinkHandler.php:27

    string

    EmailLinkHandlerTest.php:19

    missing phpdoc

    EmailLinkHandlerTest.php:63

    assertSame

    FileLinkHandlerTest.php:23

    phpdoc missing

    FileLinkHandlerTest.php:27

    files

    FileLinkHandlerTest.php:86

    assertSame

    FileLinkHandlerTest.php:113

    assertSame

    FolderLinkHandlerTest.php:22

    phpdoc missing

    FolderLinkHandlerTest.php:36

    folders

    LegacyLinkNotationConverterTest.php:25

    phpdoc missing

    LegacyLinkNotationConverterTest.php:205

    strpos === 0

    LegacyLinkNotationConverterTest.php:249

    strpos === 0

    LinkServiceTest.php:19

    phpdoc missing

    PageLinkHandlerTest.php:19

    phpdoc missing

    PageLinkHandlerTest.php:32

    spaces, also below

    UrlLinkHandlerTest.php:19

    phpdoc missing

    ContentObjectRenderer.php:6113

    htmlspecialchars

    ContentObjectRenderer.php:6131

    htmlspecialchars
  5. Wouter Wolters commented on patch set 15 06/10/16, 15:18

    Missed my general remarks/questions I don't see any type hinting, can we add this? PHP7 strict declaration should be implemented here as well IMO
  6. Benni Mack uploaded patch set 16 06/27/16, 05:32

  7. TYPO3com voted on patch set 16 V -1 06/27/16, 05:35 Completed build in 02m 57s on Mon, 27 Jun, 07:35 AM Test Summary: 9708 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-259

  8. Benni Mack uploaded patch set 17 07/11/16, 14:09

  9. TYPO3com voted on patch set 17 V -1 07/11/16, 14:13 Completed build in 03m 29s on Mon, 11 Jul, 04:13 PM Test Summary: 8 of 18636 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-752

  10. Jozef Spisiak uploaded patch set 18 07/11/16, 15:28

  11. TYPO3com voted on patch set 18 V -1 07/11/16, 15:35 Completed build in 07m 28s on Mon, 11 Jul, 05:35 PM Test Summary: 18636 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-766

  12. Benni Mack uploaded patch set 19 07/12/16, 10:02

  13. TYPO3com voted on patch set 19 V +1 07/12/16, 10:24 Completed build in 21m 59s on Tue, 12 Jul, 12:24 PM Test Summary: 18644 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-830

  14. Markus Klein uploaded patch set 20 07/19/16, 17:52

  15. TYPO3com voted on patch set 20 V +1 07/19/16, 17:57 Completed build in 05m 14s on Tue, 19 Jul, 07:57 PM Test Summary: 19506 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1136

  16. Benni Mack uploaded patch set 21 07/20/16, 21:16

  17. TYPO3com voted on patch set 21 V +1 07/20/16, 21:21 Completed build in 04m 59s on Wed, 20 Jul, 11:21 PM Test Summary: 19514 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1210

  18. Frank Nägler commented on patch set 21 CR -1 08/07/16, 11:12

    temporary -1 please check my comment

    PageLinkHandler.php:224

    imho empty check is needed here, right?
  19. Frank Nägler uploaded patch set 22 08/07/16, 13:48

  20. Frank Nägler voted on patch set 22 CR +1 V +1 08/07/16, 13:48

  21. TYPO3com voted on patch set 22 V +1 08/07/16, 13:50 Completed build in 02m 27s on Sun, 7 Aug, 03:50 PM Test Summary: 18668 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1897

  22. Georg Ringer voted on patch set 22 CR +1 08/09/16, 11:07

  23. Andreas Kienast voted on patch set 22 CR +2 V +2 08/10/16, 07:09

  24. Gerrit merged patch set 22 08/10/16, 07:09

  25. Frans Saris commented on patch set 23 08/10/16, 10:36

    Feature-74365-LinkServiceForUnifiedReferencingSyntax.rst:86

    should be **string**