Comments

Status: Needs review » Needs work

The last submitted patch, contextual-links-access-test.patch, failed testing.

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new3.07 KB

Nice find, could reproduce this as well. It's menu_contextual_links() which is responsible which keeps a static registry of parent_paths which didn't generate links and returns an empty array the third time, although you have permissions for the node.
Patch attached makes an exception on the node parent_path. Now, this will make the patch at least work, but I'm not sure if this the right way to fix this, however, we know at least where it goes wrong.

martijn houtman’s picture

@Swentel: I don't think this check is the way to go. I was looking into this as well, it happens with wildcard links, such as 'whatever/%'. The wildcard will be replaced by anything, yet the caching stores the wildcard, not what it is replaced with.

The following works for me:

if (isset($path_empty[$parent_path]) && strpos($parent_path, '%') !== FALSE) {
  return $links;
}

(sorry for not creating a patch, I am unable to right now)

(edit: formatting fixed)

swentel’s picture

StatusFileSize
new2.86 KB

Yeah, I really didn't like that solution as well :)
Trying your solution (untested, but we'll let the testbot decide). If it turns green, we'll need to get Sun in here.

sun’s picture

Status: Needs review » Needs work

Thank you!

This edge-case was/is known already, as I wasn't sure how to reasonably support it without breaking performance badly. However, this tweak looks acceptable to me.

+++ b/core/modules/contextual/contextual.test
@@ -0,0 +1,45 @@
+class ContextualNodeListTest extends DrupalWebTestCase {

Should end in TestCase, not Test.

+++ b/core/modules/contextual/contextual.test
@@ -0,0 +1,45 @@
+  function setUp() {
+    parent::setUp(array('contextual'));

Let's add

  protected $profile = 'testing';

at the very top of this test case, and afterwards, add 'node' to the list of modules to install.

Lastly, add this before creating the user:

    $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
    $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new3.08 KB

new patch

martijn houtman’s picture

Thanks guys! Any chance this will be back-ported to 7.x?

Niklas Fiekas’s picture

Issue tags: +Needs backport to D7

Yeah, I think it should be.

Status: Needs review » Needs work

The last submitted patch, 1425280-6.patch, failed testing.

sun’s picture

+++ b/core/modules/contextual/contextual.test
@@ -0,0 +1,48 @@
+/**
+ * Tests contextual links on node lists with different permissions.
+ */
+class ContextualNodeListTestCase extends DrupalWebTestCase {

ContextualDynamicContextTestCase would actually sound more appropriate.

+++ b/core/modules/contextual/contextual.test
@@ -0,0 +1,48 @@
+    $web_user = $this->drupalCreateUser(array('access contextual links', 'edit any article content'));

You likely need to add 'access content' here to fix the test failures.

+++ b/core/modules/contextual/contextual.test
@@ -0,0 +1,48 @@
+   * Creates an article node, a page node and another article node promoted to
+   * the front page and ensures the contextual links are displaying.

Just:

"Tests accessible links after inaccessible links on dynamic context."

(possibly also adjust the test method name)

Niklas Fiekas’s picture

Status: Needs work » Needs review
StatusFileSize
new1.67 KB
new3.02 KB

Reroll with your suggestion from here and IRC.

Edit: The interdiff is wrong.

sun’s picture

+++ b/core/modules/contextual/contextual.test
@@ -0,0 +1,47 @@
+/**
+ * Tests contextual links on node lists with different permissions.
+ */
+class ContextualDynamicContextTestCase extends DrupalWebTestCase {
...
+  /**
+   * Tests accessible links after inaccessible links on dynamic context.
+   */
+  function testNodeLinks() {

The phpDoc on the class and the test method looks somewhat reversed to me :)

Aside from that, this looks good to me.

(Note that another test-only patch wouldn't hurt.)

Niklas Fiekas’s picture

Hehe. That explains my confusion with the doxygen ;)

Rerolled.

Niklas Fiekas’s picture

StatusFileSize
new2.45 KB

Forgot the files[] = contextual.test in the test only patch above. So that will likely pass, because the test won't even run.

Status: Needs review » Needs work

The last submitted patch, 1425280-contextual-14-test-only.patch, failed testing.

sun’s picture

Status: Needs work » Reviewed & tested by the community

Thank you!

Extra points and huge credits for introducing the first test for Contextual module! :)

dries’s picture

Version: 8.x-dev » 7.x-dev

Committed to 8.x. Thanks. Moving to 7.x.

Niklas Fiekas’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs backport to D7
StatusFileSize
new2.42 KB
new2.97 KB

Backport.

Status: Needs review » Needs work

The last submitted patch, 1425280-contextual-18-test-only.patch, failed testing.

Niklas Fiekas’s picture

Status: Needs work » Needs review
xjm’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

Backport looks good. (Tagging for posterity.) One comment is a little weird, but not important enough since it went into 8.x already. I smell a novice issue. :)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Oooh. Yay for contextual.module tests!

Committed and pushed to 7.x. Thanks!

xjm’s picture

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