Problem/Motivation
Part of #2010184: [meta] convert ‘uri_callback’ entities param to EntityInterface::uri() method
Current state: the functions is not used after #1970360-78: Entities should define URI templates and standard links
Needs to implement Plugin\Entity\Comment.php uri()
method and deprercate comment_uri()
function replacing it's calls to $comment->uri()
and clean-up Comment annotation uri_callback
1 usage in contrib found http://grep.xnddx.ru/search?text=comment_uri&filename=
Proposed resolution
- deprecate comment_uri()
in favor of Comment::toUrl()
- probably it needs to update docs because Comment::permalink()
should be deprecated too #2113323: Rename Comment::permalink() to not be ambiguous with ::uri()
Remaining tasks
- add deprecation test
- review, commit
User interface changes
no
API changes
deprecated comment_uri()
Data model changes
no
Release notes snippet
no
Comment | File | Size | Author |
---|---|---|---|
#45 | 2010202-45.patch | 656 bytes | andypost |
#40 | drupal9.comment-module.2010202-40.patch | 633 bytes | andypost |
#39 | drupal9.comment-module.2010202-39.patch | 1.03 KB | andypost |
#10 | comment-2010202-10.patch | 1.58 KB | garphy |
Comments
Comment #1
InternetDevels CreditAttribution: InternetDevels commented.
Comment #2
kgoel CreditAttribution: kgoel commentedComment #4
kgoel CreditAttribution: kgoel commented#2: comment-2010202-2.patch queued for re-testing.
Comment #5
tstoecklerThis is missing the fragment. It should be kept like it was before.
Comment #6
garphy CreditAttribution: garphy commentedPatch in #2 was not applying correctly anymore on HEAD. Rerolled.
Comment #7
garphy CreditAttribution: garphy commented@tstoeckler, regarding #5, maybe it's up to the presentation layer to use ->permalink() instead of ->uri().
Entity::uri() should remain the canonical URI of the entity, without any fragment, no ?
Comment #8
tstoecklerI'm not really an expert on the whole comment URI / permalink question. But I remember that choosing this URI was discussed in-depth and had very specific reasoning (which I can't recall now). So if you think the fragment should not be part of the URL, please open another issue. For now, let's just straight port this. That would be awesome, thanks!
Comment #9
garphy CreditAttribution: garphy commentedI would be glad to finish that as a straight port. Could you please recover some pointers referring to that discussion? I would be happy to get more insight on this.
Comment #10
garphy CreditAttribution: garphy commentedThis patch includes the fragment.
Comment #12
andypostActually after https://drupal.org/node/2020491 this function does not work because URI is generated via 'links' property and fragment is skipped
Not sure we need to override uri() method without checking $rel and calling parent::uri($rel)
Seems for 'canonical' is not allowed to have 'fragment'
Comment #13
BerdirSee the original issue where this was added, it is not supported and was therefore dropped.
I don't rreally agree with that discussion/conclusion but that's what has been done.
Comment #14
andypostAs we have
$comment->permalink()
and this code is not used anymore since #1970360-78: Entities should define URI templates and standard linksComment #15
larowlanwinning
Comment #16
jibran#1978904: Convert comment_admin() to a Controller needs a reroll then.
Comment #17
andypostAccording #1978904-64: Convert comment_admin() to a Controller we have 3 different functions to generate permalink and
comment/ID
links to make DX betterComment #18
andypostThe proper fix for that should combine #2111419: Remove CommentManager::getParentEntityUri() in favor of Comment::permalink()
1)
Comment->permalink()
should point to actual commentcomment/123#comment-123
2)
Comment->getCommentedEntityURI()
should point tonode/1#comment-123
Comment #19
andypostMarked #2111419: Remove CommentManager::getParentEntityUri() in favor of Comment::permalink() as duplicate
Postponing on #2113323: Rename Comment::permalink() to not be ambiguous with ::uri()
Comment #19.0
andypostrelated #1970360-78
Comment #20
andypostComment #21
sunGiven how much of a regression D7's comment permalinks present for drupal.org (cf. #2125397: Enable comment_fragment 7.x-1.x-dev to improve issue comment permalinks), I definitely think we should fix this for D8.
What follows is essentially quoting myself from 2009: #26966-97: Fix comment links when paging is used.
The original change was meant to solve two discrete issues:
(2) is fully resolved by canonical URI meta tags in core today. Any search engine that doesn't respect that is not worth to support.
(1) can be resolved in the exact same way, but more user-friendly today though:
↓
/comment/$id
URI is replaced with the URI of the context.?comment=$id
query string./comment/$id
is a separate and separately cached URI, too: Zero difference.Now, if you additionally take the architectural concern of comment #20 in #2113323-20: Rename Comment::permalink() to not be ambiguous with ::uri() into account, we actually arrive at this:
As a result, the most sane architecture and technical implementation I can think of is this:
Turn
Comment::permalink()
into this:Make {whichever-code} that generates the permalinks for comment fields attached to other entities call this:
→ resulting in e.g.
/node/12345?comment=45678#comment-45678
The real gist: Add a Request event subscriber to Comment module, which
/node/12345
)->query->has('comment')
I originally planned to code this up myself, but I have too many other issues on my plate right now. My hope is that someone else is able to pick this up and turn this concept into an implementation.
Comment #22
andypostThe problem here that we need to query database in request subscriber to make sure that comment exists on given page.
Suppose this solvable except that this subscriber would fire on each entity route
Comment #23
catchThat's not zero difference.
In one case you have a GET request which always returns a 200 and doesn't require any runtime checks. Sites with a relatively low number of comments per page will end up doing lots of 302 redirects, which is completely uncacheable.
Let's take a Drupal.org issue thread with over 300 comments, but which hasn't seen an update for several hours. Every time a comment link on the second page gets visited, whether by humans or crawlers, it'll always be a 302 whereas with the current scheme it'll be in varnish.
There's no redirect in Drupal 7, there's a menu_execute_active_handler() call, and a subrequest in 8.x.
Comment #24
mgiffordComment #27
larowlanComment #28
fil00dl CreditAttribution: fil00dl at Skilld commentedHere is my short review regarding the most popular "comment hosting services" :
FACEBOOK comments module :
All comments are visible on a single page with a « display n others comments » button displayed at the top. By default it display last comments and collapsing old ones.
DISQUS :
https://disqus.com/
All comments are visible on a single page with a « load more comments » button displayed at bottom.
permalink example : https://disqus.com/home/channel/selectstart/discussion/channel-selectsta...
LIVEFYRE :
All comments are visible on a single page with a “load comments” button displayed at bottom.
See example on http://mashable.com/ which implements this comment hosting service
MUUT :
https://muut.com/demos/basic-forum.html
All comments are visible on a single page with a “more” button displayed at bottom (the label of the button is a number which indicate the count of hidden comments).
permalink example : https://muut.com/demos/basic-forum.html#!/exhibitions:this-is-my-statement
DISCOURSE :
http://try.discourse.org/t/what-happens-when-a-topic-has-over-1000-repli...
All comments are visible on a single page through an infinite scroll :
Whether the user goes directly to a specific comment with the comment ID, the system will load the previous five and ten next comments which surrounds the specific comment.
WORDPRESS default comments system :
It displays all comments on a single page, without hiding the old ones.
permalink example : wordpress_site/2015/09/30/hello-world/#comment-5
All comments are displayed together, not possible to display a single comment with the permalink.
To sum up : with the modern "comment hosting services", there is never pagination for the comments display.
The more sophisticated solution is the “infinite scroll”.
Comment #37
andypostIS needs update cos deprecation of
comment_uri()
still makes sense, not sure as it bugComment #38
andypostupdated IS
Comment #39
andypostLet's see effect of removal
Comment #40
andypostAdded deprecation, CR still needed but let's see how often it's used
Comment #44
catchUpdated the issue title, this is just a straightforward deprecation now. Needs a re-roll updating the deprecation version.
Comment #45
andypostFiled CR https://www.drupal.org/node/3384294
and updated patch, looks there's no test for
uri_callback
annotation in comment entityAlso it needs update hook to clear entity definition cache, and let's see if something will be broken with deprecation only
Looking for better wording as
Comment::permalink()
is useless #2113323: Rename Comment::permalink() to not be ambiguous with ::uri()That's reason why issue used to have such title
Comment #46
andypostupdated IS
Comment #47
catchComment::permalink() isn't useless, it's necessary to link to a comment in the context of the thread (with the correct page and comment fragment). I think we can just tell people to use that until it's renamed. However why not recommend $comment->uri() here?