Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Every time I try to write tests for something related to node access, I spend a good 30 minutes re-parsing what, exactly, the module is supposed to do.
Comment | File | Size | Author |
---|---|---|---|
#35 | d7-1674870-35.patch | 5.64 KB | joshi.rohit100 |
#30 | interdiff-1674870-28-30.txt | 510 bytes | amitgoyal |
#30 | improve_documentation-1674870-30.patch | 6.36 KB | amitgoyal |
Comments
Comment #2
xjmSomewhat related (maybe a followup), I think
NodeQueryAlterTest
should possibly beNodeAccessQueryAlterTest
.Comment #3
xjmComment #5
xjm#3: node_access_test_docs-1674870-1.patch queued for re-testing.
Comment #6
jhodgdonFixing up this documentation seems like an excellent idea, thanks!
I saw a couple of things in the patch that I think are not quite accurate:
a) @file header to node.module:
The variable I see in the code is node_test_node_access_all_uid, which seems to be setting the UID that has access to all content? (I'm looking at the 8.x code.)
b) grants hook:
I think this is called node_access_test_author, not node_access_test
c) grants hook:
See note on variable in (a).
d) Nitpick: Refer to "the Node module" (capitalized).
e) I think the patch should not make this change in the code:
Comment #7
xjm#3: node_access_test_docs-1674870-1.patch queued for re-testing.
Comment #9
xjmComment #10
pwieck CreditAttribution: pwieck commentedReroll to get things back on track.
Comment #11
jhodgdonThanks for the reroll! Setting status as per #6, assuming this latest patch is just a reroll.
Comment #12
pwieck CreditAttribution: pwieck commentedDisregard this post
Comment #13
pwieck CreditAttribution: pwieck commented@jhodgdon, I think this addresses all #6.
Comment #14
jhodgdonThanks! There are still a couple of problems in this patch (sorry, may have missed them in previous reviews):
a)
When using namespaces in documentation, always start with \ -- this affects several other lines in the patch as well.
b) I looked through the code and there is a third configuration variable in use:
node_access_test_secret_catalan
This is not mentioned in the @file header.
Other than that, this looks great!
Comment #15
pwieck CreditAttribution: pwieck commented@jhodgdon made #14 changes. I don't know if I have the 'node_access_test_secret_catalan:' right. Here is what I came up with.
Comment #16
jhodgdonYeah, that's what I thought the Catalan thing was doing too. :)
The only thing now is that this line in the @file header:
should say "three" not "two". :)
Comment #17
xjmAlso, they're now "state variables" rather than "configuration variables". :)
Comment #18
jhodgdonOh really? Where? I was looking at some API documentation today and it seemed to be all still called "configuration variables" -- that was the update function. If the terminology is being updated, it needs to be updated everywhere, not piecemeal...
Comment #19
xjm@jhodgdon, it's not a change in terminology, it's a change in the functional code since this docs patch was written. This test now uses the Drupal 8 state system, not the Drupal 7 configuration variable system. See here:
http://drupalcode.org/project/drupal.git/blob/refs/heads/8.x:/core/modul...
Comment #20
xjmAlso, a cleanup would be out of scope for this patch anyway. Presumably, anything that refers to configuration variables is referring to legacy D7 code that hasn't been converted to config or state yet. If not, then it's a docs bug for that specific place in the codebase.
Comment #21
drs2034 CreditAttribution: drs2034 commentedI'm at the Austin sprint, I will be working on rerolling it.
Comment #22
vegantriathleteComment #23
drs2034 CreditAttribution: drs2034 commentedRerolled
Comment #24
drs2034 CreditAttribution: drs2034 commentedMissed slash in drupal global namespace.
Comment #25
cilefen CreditAttribution: cilefen commented@theemg You did an awesome job on your first reroll. The actual details in question are beyond my ken at this stage. Perhaps @xjm or @jhodgdon can comment.
Comment #26
JacobSanfordRemoving 'Needs reroll' as patch applies cleanly.
Comment #27
jhodgdonThanks for the rerolls!
I have reviewed the documentation for this module carefully, and it is mostly great. Still needs a few fixes:
a) In the @file doc block at the top, it talks about configuration variables, but they are actually state variables. This error is repeated in many function doc blocks below.
b) Same place - talks about there being 2 variables but then lists 3 variables. For future maintainability, maybe say "the following" or something like that instead of saying how many?
c) There's a doc line in node_access_test_node_grants that runs over 80 characters:
Needs rewrapping.
d) There is only one code comment in node_access_test_node_grants(), which says "First, ..." and describes what the first node grant is. I think we should either take this comment out (the functionality is clearly documented now in the function header) or add comments for the other grants. Either way.
e) Missing from this patch: We need to remove the blank line here between documentation and function:
f) Missing from this patch:
This needs a new one-line doc that tells what the function does, starting with a 3rd-person verb. Probably something like "Saves the private status of the node in the database."
Comment #28
amitgoyal CreditAttribution: amitgoyal commentedPlease review the revised patch with fixes in #27. I have fixed all the points in a, b, c, d, e, f.
Comment #29
jhodgdon99% there!
This "Saves the private status..." line needs to be the first line of the function documentation. I think actually that we could get rid of the "Helper for ..." line -- either it should list the actual functions that it is a helper for, or we should remove it, and if we keep it, it needs to go below the other line.
Thanks!
Comment #30
amitgoyal CreditAttribution: amitgoyal commentedI have removed the "Helper for node insert/update" line as per #29. Please review.
Comment #31
jhodgdonThanks! This one looks good to me. Go Amit!!!
Comment #33
jhodgdonThanks again everyone! Committed to 8.x.
This also needs to be ported to 7.x, keeping in mind that @see references to test classes are probably different there, and there is no such thing as a "state variable" in 7. So just putting the same patch on for D7 is not going to work. It will need a little editing.
Comment #34
xjmThe original patch in #3 is probably more accurate for D7, so it's a matter of incorporating some of the subsequent improvements into that patch.
Comment #35
joshi.rohit100D7 patch for this.
Please review now.
Comment #36
jhodgdonIn Drupal 7, "state variables" do not exist. So:
That is not correct.
So it looks like the patch from Drupal 8 was just applied to Drupal 7 blindly. Before I give it a full review, can you please go through the documentation that is added and see if it actually all applies to Drupal 7? For instance, I am not sure if the test class names are the same, and I am not sure if all the functionality in the Drupal 8 version of the test module actually exists in the Drupal 7 version. Thanks!
Comment #37
xjmAgain, I'd suggest starting from the patch in #3 instead.