Current: db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() == 1 || $op == 'update' || $op == 'delete'
Could be: $op == 'update' || $op == 'delete' || db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() == 1
Patch attach changes the order it, but did against a freshly checked out copy 8.x.. so hopefully no syntax errors.
Comment | File | Size | Author |
---|---|---|---|
#14 | drupal_1439336_node_revision_acess_14.patch | 6.78 KB | hefox |
#11 | drupal_1439336_node_revision_acess_11.patch | 4.53 KB | hefox |
#9 | drupal_1439336_node_revision_acess_8.patch | 4.76 KB | hefox |
#7 | drupal_1439336_node_revision_acess_6.patch | 2.53 KB | hefox |
#6 | drupal_1439336_node_revision_acess_5.patch | 2.53 KB | hefox |
Comments
Comment #1
kafitz CreditAttribution: kafitz commentedIndeedn, It seems better that the if-statement first checks if op is delete or update. I tested the patch and all went fine. Seems good to me.
Comment #2
xjmBased on experiences in #1064954: _node_revision_access() static usage I'd like to see some nice robust test coverage to go with this.
Comment #3
xjmSo to clarify my previous comment, it would be good to add test coverage for the particular flow branch of _node_revision_access() that the patch changes. In this, case, that's if the node is the current revision, and it is either the only revision, or the user is trying to update or delete it.
There are two non-mutually-exclusive possibilities for tests:
NodeRevisionPermissionsTestCase
, that tests the return value of_node_access_revision()
in all these cases.Comment #4
Kristen PolComment #5
hefox CreditAttribution: hefox commentedTests for 1)
Comment #6
hefox CreditAttribution: hefox commentedTypo
Comment #7
hefox CreditAttribution: hefox commentedAnother typo
Comment #8
xjmThat test coverage looks good to me. So we just need the functional tests, then.
Couple minor cleanups:
Let's make this "delete or update" so that it's a more complete sentence.
This comment is over 80 chars, so let's wrap it. I'd also say "view, update, or delete".
Comment #9
hefox CreditAttribution: hefox commentedabove + a try at functional test, not sure how to handle the user object for drupalGet
Comment #10
xjmLet's remove this. Each test method gets its own session, so we don't need to restore the logged-in user. Also, we probably shouldn't muck with data for the test in the parent site environment.
Edit: Also, if need be, we can create a separate test method.
Comment #11
hefox CreditAttribution: hefox commentedOne of the test stores $GLOBAL user just after than, sets admin user, then rests after. Removed that also and added a login for admin user, which is a user needed for that test and for rest of coming tests.
Comment #12
hefox CreditAttribution: hefox commentedComment #13
xjmAh. I see now why you were using this. The purpose here was to test the function used the correct default account when the account wasn't passed (i.e. no third parameter for
_node_revision_access($revision, 'view')
). Running within the test case, it will actually default to the current user in the parent environment (not$admin_account
), so the fact that the patch passes with this hunk is (I think) misleading. I think if we switched it to an unprivileged user and tested for FALSE instead, it would probably fail.Since we're passing the account parameter in the assertions immediately below this hunk, I am not sure we should have the the
drupalLogin()
where it is.I'd say we should open a followup for testing
_node_revision_access($revision, 'view')
without passing the account parameter, and maybe we should also move the functional assertions into their own method? Edit: we could even create that extra node insetUp()
. What do you think?Comment #14
hefox CreditAttribution: hefox commentedWell, that's unexpected.
Anyhow, tried moving the functional parts to their own test, but keeps failing due to being unable to login some users (wrong username or password on user login form). I'm a bit confused.
Anyhow, node creation moved to setup, and all functional tests moved together to bottom, but still in same function, but assuming can fix the above issue, can split them two two functions.
Comment #15
johnv#808730: Show the Revisions tab/page even when only one revision exists. changes the same line of code and has an extra use case.
Should we merge the two issues? Or better leave this as the 'test'-issue vs. the other 'patch'-issue
The patch-code seems to change regularly, whereas the test-code should be stable.
Comment #16
socketwench CreditAttribution: socketwench commentedNovice issue cleanup.
Comment #17
jhedstromPatch no longer applies.
Comment #18
Guybrush Threepwood CreditAttribution: Guybrush Threepwood as a volunteer commentedDoes this mean that everything needs to be redone?
Comment #19
deepakaryan1988Comment #20
deepakaryan1988Comment #23
cchanana CreditAttribution: cchanana commentedComment #24
cchanana CreditAttribution: cchanana commentedComment #25
iMiksuLet start rerolling
Comment #26
iMiksuOK, Teemu is taking this! He already started on it.
Comment #27
teemuaro CreditAttribution: teemuaro at Drontti Oy commentedSorry about forgetting to assign this to me :)
Comment #28
teemuaro CreditAttribution: teemuaro at Drontti Oy commentedThis one seems to be outdated and not relevant anymore. Feel free to reopen though if I'm mistaken.
Comment #29
teemuaro CreditAttribution: teemuaro at Drontti Oy commentedComment #30
niyon CreditAttribution: niyon commented