Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shanethehat’s picture

Assigned: Unassigned » shanethehat

I'll try this

shanethehat’s picture

Status: Active » Needs review
FileSize
3.79 KB
shanethehat’s picture

Assigned: shanethehat » Unassigned
andypost’s picture

Status: Needs review » Needs work
+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,66 @@
+      $request = drupal_container()->get('request');

why not inject request here too?

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,66 @@
+      $_GET['page'] = $page;
+      return drupal_container()->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST);

subrequest === redirect?

dawehner’s picture

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,66 @@
+* @file
+* Contains \Drupal\comment\Controller\CommentController.
+*/

Missing spaces.

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,66 @@
+   * @return

What is the expected return value in this case?

shanethehat’s picture

Assigned: Unassigned » shanethehat
Status: Needs work » Needs review
FileSize
4.59 KB
shanethehat’s picture

Assigned: shanethehat » Unassigned

Status: Needs review » Needs work

The last submitted patch, comment-permalink-controller-1978914-6.patch, failed testing.

dawehner’s picture

+++ b/core/modules/comment/lib/Drupal/comment/CommentRequestController.phpundefined
@@ -0,0 +1,88 @@
+   * @var Symfony\Component\HttpFoundation\Request
+   */
+  protected $request;
...
+    return new static($container->get('request'), $container->get('http_kernal'));
...
+   * @param Symfony\Component\HttpFoundation\Request $request
...
+  public function __construct(Request $request, HttpKernelInterface $http_kernal) {
...
+  public function commentPermalink(Comment $comment) {

Just in general you don't need to inject the request into the controller. What you can do instead id to add Request $request on the actual controller method. This will be passed in magically/automatically.

mparker17’s picture

Assigned: Unassigned » mparker17

I'll help!

mparker17’s picture

Assigned: mparker17 » Unassigned
Status: Needs work » Needs review
FileSize
2.96 KB
4.33 KB

Okay, let's try this.

I noticed that "kernel" was misspelled in multiple places, including the DI tag, so I've fixed it and ensured that the DI tag being used is correct.

Also, class properties are supposed to be in camelCase, so I've done that too.

dawehner’s picture

Assigned: Unassigned » mparker17
Status: Needs review » Needs work

Please always adapt the original code: hook_menu and remove the existing code.

mparker17’s picture

Assigned: mparker17 » Unassigned
Status: Needs work » Needs review
FileSize
1.29 KB
4.38 KB

hook_menu entry removed. And, I made the tests pass.

Moved the Controller into a Controller sub-namespace as per @Crell's recommendation in IRC.

dawehner’s picture

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentRequestController.phpundefined
@@ -0,0 +1,80 @@
+      if (!entity_page_access($node, 'view')) {

You can also just use $node->access('view') instead

mparker17’s picture

Assigned: Unassigned » mparker17
Status: Needs review » Needs work

Setting to needs work; I'll try to fix it tonight.

juampynr’s picture

Status: Needs work » Needs review
FileSize
4.36 KB

Replaced entity_page_access($node, 'view') by $node->access('view').

The permalink request still works as expected after this change.

mparker17’s picture

Assigned: mparker17 » Unassigned

Ah, thanks @juampy! Unassigning from myself.

andypost’s picture

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentRequestController.phpundefined
@@ -0,0 +1,80 @@
+ * Contains \Drupal\comment\CommentRequestController.
...
+class CommentRequestController implements ControllerInterface {

Please place it in \Drupal\comment\Controller\CommentController as #1907960-187: Helper issue for "Comment field" does

andypost’s picture

mparker17’s picture

Renamed controller to Drupal\comment\Controller\CommentController

mparker17’s picture

Assigned: Unassigned » mparker17
Status: Needs review » Needs work

Sigh, the comment at the top of the file is wrong.

mparker17’s picture

Assigned: mparker17 » Unassigned
Status: Needs work » Needs review
FileSize
534 bytes
4.33 KB

Lets try this again...

andypost’s picture

Now you need to drop comment_permalink() old function and update comment_menu() with route_name

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,80 @@
+      // @todo: Cleaner sub request handling.
+      $redirect_request = Request::create('/node/' . $node->nid, 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all());
+      $redirect_request->query->set('page', $page);
+      // @todo: Convert the pager to use the request object.
+      $_GET['page'] = $page;
+      return $this->httpKernel->handle($redirect_request, HttpKernelInterface::SUB_REQUEST);

Still think that redirect is better...
A kind of
return new RedirectResponse(url('/node/' . $node->id(), array('absolute' => TRUE)));
should be enough

mparker17’s picture

Assigned: Unassigned » mparker17
Status: Needs review » Needs work

Okay, I'll do that.

dawehner’s picture

@andypost
Let's please not change the functionality. This was discussed in #26966: Fix comment links when paging is used. and saving another bootstrap is a valid point.

mparker17’s picture

Assigned: mparker17 » Unassigned

Unfortunately, I haven't had the chance to work on this recently. Unassigning from myself - hopefully someone else can pick it up. Sorry :(

dawehner’s picture

Status: Needs work » Needs review
FileSize
4.49 KB
6.71 KB

Addressed the main point of andypost's comment.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Awesome!

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/comment/comment.moduleundefined
@@ -15,6 +15,7 @@
+use Drupal\comment\Plugin\Core\Entity\Comment;

@@ -76,8 +77,6 @@
-use Drupal\comment\Plugin\Core\Entity\Comment;

I don't see how this is in scope, but if the typehint is still used it should be \Drupal\comment\CommentInterface

+++ b/core/modules/comment/comment.moduleundefined
@@ -221,10 +220,7 @@ function comment_menu() {
-    'access callback' => 'entity_page_access',
-    'access arguments' => array(1, 'view'),

+++ b/core/modules/comment/comment.routing.ymlundefined
@@ -4,4 +4,9 @@ comment_edit_page:
+    _access: 'TRUE'

This should be _entity_access: 'comment.view'

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,86 @@
+use Drupal\comment\Plugin\Core\Entity\Comment;
...
+   * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment
...
+  public function commentPermalink(Request $request, Comment $comment) {

This should be \Drupal\comment\CommentInterface

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,86 @@
+   * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
+   * @return \Symfony\Component\HttpFoundation\Response

Missing a blank line

+++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.phpundefined
@@ -0,0 +1,86 @@
+      // Check access permissions for the node entity.
+      if (!$node->access('view')) {
+        throw new AccessDeniedHttpException();

This should be handled by the route requirements

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.7 KB
6.32 KB

Thanks for the review!!

This should be handled by the route requirements

I would like to, but how do we define two keys _entity_access in the routing yml file :(

star-szr’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

This needs a reroll.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.29 KB

Rerolled, it just conflicted with drupal_container() being replaced

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Let's get this in

andypost’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.69 KB

Rerolled.

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, comment-1978914-35.patch, failed testing.

star-szr’s picture

Status: Needs work » Needs review
Issue tags: +WSCCI-conversion

#35: comment-1978914-35.patch queued for re-testing.

twistor’s picture

Status: Needs review » Reviewed & tested by the community

Looks purty.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6ac2f8e and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

andypost’s picture