Problem/Motivation

The Views field 'Link to edit' creates the following link: /user/1/edit?destination%5Bdestination%5D=/admin/people

This should be /user/1/edit?destination=/admin/people

Proposed resolution

Fix the destination parameter in 'Link to edit user' to include only one destination parameter.

Remaining tasks

  • Write a patch
  • Review

User interface changes

None

API changes

None

Comments

dawehner’s picture

This is currently broken due to #2404603: Add proper support for Url objects in FieldPluginBase::renderAsLink(), so we can remove EntityInterface::getSystemPath() but I think this issue os worth to keep to for example add dedicated test coverage.

idebr’s picture

Title: Views field 'Link to edit user' is no link » Views field 'Link to edit user' has a duplicate destination parameter, returns WSOD

#2404603: Add proper support for Url objects in FieldPluginBase::renderAsLink(), so we can remove EntityInterface::getSystemPath() has been committed and the 'Link to edit user' now renders a link. However, the destination parameter has another destination parameter. This kills the website.

idebr’s picture

Title: Views field 'Link to edit user' has a duplicate destination parameter, returns WSOD » Views field 'Link to edit user' has a destination parameter, returns WSOD
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new732 bytes

Attached patch removes the destination parameter from the destination parameter. I updated the issue summary to reflect the new issue.

idebr’s picture

Title: Views field 'Link to edit user' has a destination parameter, returns WSOD » Views field 'Link to edit user' has a duplicate destination parameter, returns WSOD
dawehner’s picture

Would you mind trying writing a test?

idebr’s picture

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

Sure, I'll write a test :)

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new2.58 KB
new2.58 KB
new3.29 KB

Tests added. I wonder what is the best way to test the destination parameter on the 'Edit' link in a test? Right now its hardcoded to the current path.

The last submitted patch, 7: 2401265-7.fail_.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 7: 2401265-7.patch, failed testing.

idebr’s picture

Assigned: idebr » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.68 KB
new1.03 KB
new3.4 KB

Alright, this should fix the failing test to fail only on the Edit link failure.

The last submitted patch, 10: 2401265-10.fail_.patch, failed testing.

dawehner’s picture

This doesn't block this bug to get in. Can we please add a quick beta evaluation?

+++ b/core/modules/user/src/Tests/Views/UserLinkEditTest.php
@@ -0,0 +1,40 @@
+ */
+class UserLinkEditTest extends UserTestBase {
+

In case you want to you could try to write a kernel test instead, as it would make it way nicer to run the test, due to its better performance.

idebr’s picture

Oh, that sounds good. I haven't written one before but i'll have a look tomorrow.

dawehner’s picture

FieldCounterTest might give you an idea how to do it.

idebr’s picture

Status: Needs review » Needs work
StatusFileSize
new5.45 KB

I tried extending UserUnitTestBase but I couldn't get the user edit link to render in the test. Other fields such as the user name were rendering fine. Do I need to override any access checks for the edit link to show up?

lendude’s picture

Status: Needs work » Closed (works as designed)

This handler was removed in #2322949: Implement generic entity link view field handlers and now the \Drupal\views\Plugin\views\field\EntityOperations is used.