Problem/Motivation
There is no way to enable revision permissions per content type.
Proposed resolution
- Add revision permissions per content type.
- Retain the existing global revision permissions.
Patch in #189 implements this feature.
Remaining tasks
The patch in #189 includes automated tests and has been reviewed for coding standards. It should be manually tested to ensure it behaves as expected.
Follow these steps to test the patch:
- Create a Drupal 8.x sandbox site.
- Create a few user accounts with various revision permissions.
- Apply the patch and run update.php.
- Ensure that the permissions are updated correctly.
- Add some per-content type revision permissions and ensure permissions behave as expected.
User interface changes
View Revisions, Edit Revisions, and Delete Revisions permissions will be added to each content type. See the screenshot below.

Changes Strings:
- 'View revisions' to 'View any revisions'
- 'Revert revisions' to 'Revert any revisions'
- 'Delete revisions' to 'Delete any revisions'
Adds Strings:
- '%type_name: View revisions'
- '%type_name: Revert revisions'
- '%type_name: Delete revisions'
API changes
API Addition: The following permissions will be added.
view {$type} revisionsrevert {type} revisionsdelete {type} revisions
API Change: The following permissions will be renamed.
view revisionstoview all revisionsrevert revisionstorevert all revisionsdelete revisionstodelete all revisions
Original report by realityloop
I was trying to do something with revisions today and came against an instance where I would like to grant view revisions on a particular node type, it seems a level of flexibility could be added by splitting the revisions permissions per node type rather than globally
| Comment | File | Size | Author |
|---|---|---|---|
| #191 | drupal-880940-191-tests.patch | 16.67 KB | realityloop |
| #191 | drupal-880940-191-combined.patch | 22.21 KB | realityloop |
| #189 | drupal-880940-189-tests.patch | 16.67 KB | realityloop |
| #189 | drupal-880940-189-combined.patch | 22.21 KB | realityloop |
| #188 | drupal-880940-188-tests.patch | 0 bytes | realityloop |
Comments
Comment #1
realityloop commentedpatch attached for D6
Comment #2
realityloop commentedDrupal 7 patch attached
Comment #3
realityloop commentedstatus change
Comment #4
dries commentedThis makes a lot of sense to me. If we all think this is a good idea, we'll certainly need an upgrade path.
This feature might have to wait until Drupal 8 though.
Comment #6
realityloop commentedFor upgrade path would assigning view/revert/delete to all content types if they have view/revert/delete revisions before the change make sense to people?
It seems the logical way to me so I will work on it today.
Comment #7
realityloop commentedNow with migration path!
Comment #8
realityloop commentedAdded required change to node.test file
Comment #10
realityloop commentedadded change to rdf.test
Comment #12
realityloop commentedTotally rewrote migration function, hopefully will pass tests now
Comment #13
realityloop commentedEdits for reading ease
Comment #14
realityloop commentedRemoved unneeded piece of code.
Comment #15
lyricnz commentedLooks good, and could be useful flexibility. I'd RTBC this apart from one minor niggle: When creating the user in node.test, it should enable perms just for "page", not for all types. You can then just use a static array of perms, too.
Comment #16
realityloop commentedThanks for the feedback, fix for node.test attached and also changed 'Migrated' to 'Migrate' in install function as I think it is more accurate tense
Comment #17
lyricnz commentedLooks good to me - RTBC conditional on passing the testbot.
Comment #18
chx commentedFeature. freeze. Which of these two words we can't understand? We make exceptions for bugs / regressions / performance problems. This is neither. This is a genuine new feature.
Comment #19
cafuego commentedSet back to 7.x, considering Dries original comment.
Comment #20
chx commentedNo. Dries said, if we all think. I certainly don't. We are not adding features.
Comment #21
rcross commentedI'm not sure if Dries meant that "everyone" = chx, but I think this warrants getting into D7 since it borders on a bug considering all the fieldable entities now and revisions is not behaving like other CRUD functions.
+1 from me.
Comment #22
catchAgreed with chx, feature requests go in Drupal 8. Also there's nothing in here which couldn't be implemented in contrib if people want it for D7.
Comment #23
realityloop commentedI totally understand if this has to wait until D8, but Dries didn't change it to 8.x-dev, and as core maintainers shouldn't it be Dries or Webchick that decide?
Comment #24
webchickThere. Decided.
It's possible this might be one of those changes we could backport from D8, once D7 it out the door, but in the meantime we really need to not expend energy on feature patches 12 months after feature freeze.
Comment #25
thyjhay commented#2: per-content-type-revision-controlsd7.patch queued for re-testing.
Comment #26
realityloop commented#16: per-content-type-revision-controlsd7-with-migrate-path.patch queued for re-testing.
Comment #27
realityloop commentedPatch rerolled for testing on D8 against 8.x git repo
Comment #28
realityloop commentedForgot to change status
Comment #29
berdirJust testing if the patch is ignored because the version is set to 8.x
Comment #30
berdirand back. The answer is yes.
Comment #32
realityloop commented#27: revisions-per-content-type-880940-3640082.patch queued for re-testing.
Comment #34
realityloop commentedPatch reworked after failed test
Comment #35
realityloop commentedReposting without D8 suffix to hopefully stop it from being ignored as suggested by berdir
Comment #36
realityloop commentedRe-added migration code as I realised it will still be needed for 7->8 upgrades
Comment #37
larowlanextra whitespace
See comments below, but if we retain 'view content revisions' as 'view any content revisions' - this will need updating.
Could we retain these but rename them to 'Revert any content revisions' etc. That will simplify permission administration for sites with a large number of content types.
Whilst we're at it should we also introduce 'View own revisions' etc too?
These should follow the format of the existing ones - ie %type_name: View revisions - and so on - it makes the ui at admin/people/permissions much cleaner.
If we retain the existing permission as 'Revert any content revisions' this will need updating.
ditto
being picky but I don't like the variable name here.
I think we need another test here too - to test that the user without the appropriate permission gets a 404.
Powered by Dreditor.
Comment #38
realityloop commentedI'd really like to get some more feedback on this if possible?
Comment #39
realityloop commentedIncorporating feedback from #37
Comment #41
lyricnz commentedTypo
0 days to next Drupal core point release.
Comment #42
realityloop commentedOops
Comment #44
realityloop commentedUpdated
Comment #45
realityloop commentedCatch told me to use _update_7000_ versions of some functions I had in .install
Comment #46
catcht($role->name); - we probably can't use t() here. t() can hit the theme system and end up invoking hooks. But the translated string is probably never going to be necessary so I reckon that could be skipped.
This is getting very verbose - could we maybe add a _node_revision_access($operation); helper?
Everything else looks fine.
Is it worth adding tests that confirm the permissions granularity works?
Comment #47
catchSorry one more thing. The {roles} table changed in Drupal 7, so this needs to be _update_7007_user_roles() - since that's where the column was added.
Comment #48
realityloop commentedUpdate
Comment #50
realityloop commentedComment #52
realityloop commentedUpdate
Comment #54
larowlanRelated #282404: Add view [TYPE] content permission
Comment #55
realityloop commentedComment #57
langworthy commentedsub
Comment #58
realityloop commentedBetter naming of perms
Comment #60
realityloop commentedThis should pass
Comment #62
realityloop commentedFixed typo in node.install
Comment #63
realityloop commentedChanging 7007 to 7000
Comment #64
skwashd commentedShould be called
_update_8000_user_roles()to match name of calling function.This can be chained.
For readability I'd define the array outside of the fields call.
The rest looks good to me.
-22 days to next Drupal core point release.
Comment #65
realityloop commentedChanges from #64 applied
Also duplicated function _update_7000_node_get_types() { so D8 to D9 upgrade path doesn't break.
Comment #66
decipheredChained item should probably on the next line and indented.
Chained items need indentation
Too much indentation here.
I'd also change permission line to "{$action} {$type} revisions" for readability.
-22 days to next Drupal core point release.
Comment #67
realityloop commentedThanks, updated
Comment #68
decipheredNeeds more indentation, should always be indented by two spaces (only on here).
Needs out-denting, the closing parenthesis of an array should be on equal level with the opening parenthesis.
-22 days to next Drupal core point release.
Comment #69
realityloop commentedFeedback implemented and updated if statement in node.module
Comment #70
decipheredTwo checks for
isset($map[$op]), assuming the second one is supposed to be against$map1.That's serious nitpicking, but nevertheless it should be fixed.
-22 days to next Drupal core point release.
Comment #71
realityloop commentedDoh! updated
Comment #72
xjmHey realityloop, this sounds like a nice feature! The patch looks pretty complete already. Here are some additional code style pointers:
I'd suggest removing the phrase "Utility function" as these words don't really add information, and we're currently stripping stuff like that out in the docs cleanup sprint. Also, should begin with a 3rd person present indicative verb tense: "Fetches..."
"Retrieves..."
"Migrates..."
Missing newline. Just hit enter at the end of node.install to put the cursor on the next line.
Another missing newline for node.module.
Your test case classes need docblocks.
Funky indentation here; the subsequent lines should be indented by only two additional characters. You could put the permissions arrays on their own line, perhaps; that would be more readable. Also, these lines are over 80 chars by a lot.
Your test case classes should have docblocks.
Same note as above about indentation/wrapping/char limit.
Funky indentations again; same suggestion. Also, the second one is kind of hard to parse, so maybe you could put one array key on each line? That would work for the userLogin()s as well, actually.
"Checks..."
Generally: Going over 80 chars with the assertions is okay if they're easy to read, but when you do wrap them, wrap to 80 chars and put array elements on separate lines. Also, see http://drupal.org/coding-standards#array.
Thanks!
Comment #73
realityloop commentedThanks xjm, that should all have been addressed now.
Comment #74
xjmNice, that looks a lot better. Here's a few things that slipped through:
Should be "Fetches," "Retrieves," "Tests," etc. (The idea is that implied subject is "This function.")
The one end-of-file newline got fixed, but this one is still missing.
These are much easier to read. However, they're indented too much. They should only be indented by two chars from the first line.
Should start with "Tests..." Also, try to reword it a little so it's under 80 chars.
Let's break this out into separate lines like you did for the others.
Oh, I'm confused about this but I think I forgot to mention it before... what is this an @see to? Usually @see is a function name or a url.
Comment #75
realityloop commentedDone, thanks again.
Comment #76
xjmFor the update hook, I'd suggest reformatting it like:
Comment #77
realityloop commentedUpdate hook reformatted as per suggestion, thanks again
Comment #77.0
realityloop commentedUpdated issue summary.
Comment #78
decipheredTwo different coding styles are used:
'string ' . $variable;and
"string $variable";I would recommend standardizing, and if using the latter (my preference), wrap variables with {}
"string {$variable}";If you're making other arrays more readable, then these two could certainly be improved.
Getting even more nit-picky here. Otherwise it's looking pretty good.
-23 days to next Drupal core point release.
Comment #79
realityloop commented#78 suggestions implemented
Comment #80
realityloop commentedfixed indentation error
Comment #81
realityloop commentedfixing indent properly
Comment #82
realityloop commentedindent was still wrong :/
Comment #83
realityloop commentedSorry poor testbot! it should be right now..
Comment #84
realityloop commentedAdded author information
Comment #84.0
realityloop commentedUpdated issue summary.
Comment #84.1
realityloop commentedUpdated issue summary.
Comment #84.2
realityloop commentedUpdated issue summary.
Comment #84.3
realityloop commentedUpdated issue summary.
Comment #85
xjmAttaching screenshot.
Comment #85.0
xjmUpdated issue summary.
Comment #85.1
xjmPolishing markup and clarity.
Comment #86
xjmHere's some user testing that might be helpful from patch testers.
update.php.I have no idea if
update.phpis even working, but we can find out. :)I have updated the issue summary with a little more detail and a link to the current patch.
Comment #86.0
xjmUpdated issue summary.
Comment #87
dmitrig01 commentedfetches -> fetch
Not sure how these changes are related...
Other than that, looks pretty good, though I haven't actually tested it; just code review.
Comment #88
realityloop commented#87 some of that is in opposition to #74, will wait for some confirming reports before changing it back.
Comment #89
xjm#87 is incorrect. @dmitrig01, please refer to http://drupal.org/node/1354#functions. The correct verb form for the one-line summary is a third-person present tense indicative, e.g., "Does foo." (The implied subject is "the function.")
See also #1310084: [meta] API documentation cleanup sprint.
Comment #90
xjmOh, re #78 and #87 -- it is correct that you should not change coding standards that are on lines that aren't a part of your functional patch. The reason for this is it can make your patch take longer to review and makes it more likely to need rerolls if other patches target those lines. See this post for more detail: http://webchick.net/please-stop-eating-baby-kittens
Comment #91
xjmAs far as I can tell, these are all the changes with the curlies that are not needed. It would be better to remove these to make your patch less co-distruptive with other potential patches, as explained in webchick's post. :)
As an aside, I'd actually disagree with #78's choice of {}. I think concatenation with . is a more common pattern in core, and since that's the style that's already used in that test, then it would be best to continue that style. But that is a minor and bikesheddable point.
Comment #92
xjmOh, just noticed a missing period here.
Comment #93
rowbotony commentedHi, I am finding the permissions for DELETE and REVERT aren't working properly. In fact it seems that none of the checkboxes for per content type revision permissions are working after I apply this patch. I'll explain further, bear with me as I'm a n00b tester :)
I created a default D8 install via the instructions at http://drupal.org/node/28245. I then created some random content, various roles and users all with varying levels of Revision permissions. For example I created the roles of: test_revision_review, test_revision_revert, and test_revision_delete, all of which had the corresponding permissions as their title suggests.
In short - the patch works properly after applied in retaining the ticked checkboxes on the permissions screen (see screenshot). However I have found upon further testing that the REVERT and DELETE permissions are not working.
For example: if a user has REVERT only permissions, they will receive "Access Denied" when going to
node/41/revisions/41/revert. I then assigned VIEW permissions to this same user and still received "Access Denied" when going tonode/41/revisions/41/revert, same problem when I enabled all Revision permissions for all roles.After enabling all permissions I was only able view the revert screen, but still not able to actually revert or delete any revisions.
I am not familiar enough with the Drupal permission system so I'm not certain if what is happening here is in fact the way permissions are designed to work? Perhaps the user also needs Edit permissions? I hope my report helps rather than confuses.
--Tony
Comment #94
anthbel commentedAfter applying patch #84 view/revert/delete revisions global configurations are cleared.


Comment #95
rowbotony commentedI did a little more poking around, unchecked all the boxes (and cleared caches, and logged out/logged back in), and after all of the boxes are unchecked my test user still has permissions to view the revisions as in screenshot http://drupal.org/files/880940_permissions4.png above, which they should no longer have.
After unchecking all the boxes

User can stil see this

These conditions are true for both per content type revision permissions as well as the global "View any revisions, Revert any revisions, Delete any revisions" checkboxes as shown in anthbel's post above. Nothing I do (as the administrator) within those boxes now seems to affect what the test user can see on the revisions page as is shown in the above screenshot. Also, as a testing note - I am using two separate browsers for testing - Firefox for Admin tasks and Safari for user testing, etc. I'm going to take a step back now as I'm not so sure that what I've worked on here today has actually helped or not :/. Thanks for letting me play with the big kids for a while! :) --Tony
Comment #96
xjmSetting back to Needs Work to follow up on the issues seen in testing, above, and I suppose for the minor code cleanups while we're at it. :)
Comment #97
rowbotony commentedI had a different result than anthbel with the permissions checkboxes. After applying the patch on my sandbox - the Revision permissions were retained globally, as well as populated to each content type of Basic Page and Article. For example - if my test_revision_delete role had Revision DELETE permissions prior to the patch, they retained their global Revision DELETE permission and gained Revision DELETE permission on each content type after applying the patch, updating, and clearing caches.
Comment #97.0
rowbotony commentedUpdated issue summary.
Comment #97.1
xjmUpdated issue summary.
Comment #98
rowbotony commentedFor the sake of completeness, and because I'm new and want to do this properly - I started with a fresh install, and repeated all the same steps as I did in #93 and still got the same result.
-- added: Just remembered about, and tried to Rebuild Permissions
http://d8.sandbox.dev/admin/reports/status/rebuild, which did not fix the access issues. I'll be following this issue to test later when ready.Comment #99
xjmThanks to all the help with testing above (thanks tons to @drupleg and @anthbel!), I took a closer look at the update hooks. I think I have found at least one thing we can fix:
Rather than doing all this, why don't we simply update entries for the three existing permissions from (e.g.) 'view revisions' to 'view any revisions'? That should resolve some of what we're seeing above. Also, I think that would eliminate the need to look up either node types or roles, unless I'm overlooking something. Three update queries instead of lots and lots of inserts and deletes (and less code for whatever bug to be hiding in).
That leaves the step of debugging the malfunctioning permission behavior @drupleg documents. There are two possibilities: Some strange records were getting to the DB during the update, or the permissions themselves are bugged. Let's fix the update hook first, and then do some testing again after that.
Comment #100
xjmRe: #98 -- rebuilding permissions should not actually affect this. It's sort of misnamed. :)
Comment #100.0
xjmUpdated issue summary.
Comment #100.1
xjmUpdated issue summary.
Comment #100.2
xjmUpdated issue summary.
Comment #100.3
xjmUpdated issue summary.
Comment #100.4
xjmUpdated issue summary.
Comment #100.5
xjmUpdated issue summary.
Comment #101
realityloop commentedThanks to those who did the testing above!
xjm #99 was the method I planned as soon as I read the comments :)
Updated patch attached
Comment #102
xjmCool, let's get some testing again.
Comment #102.0
xjmUpdated issue summary.
Comment #102.1
xjmUpdated issue summary.
Comment #103
xjmTagging as novice to test and document the patch and upgrade path. Follow the testing instructions in the issue summary above.
Comment #104
xjmHmm, okay, I still think we can get rid of all of this and replace it with three update queries. Translate to DB API:
UPDATE role_permission SET permission = 'view any revisions' WHERE permission LIKE 'view revisions';Reference: http://drupal.org/node/310080
Is there a reason not to do this?
Edit: dreditor fail.
Comment #105
realityloop commentedredundant code removed
Comment #106
xjmRe #105 -- could you either make the patch with
git diff, or squash it? It's quite confusing to review with two commits in there. I almost posted "Errrr but it's still there, " but fortunately I scrolled to the bottom and saw the second commit. :)Comment #107
realityloop commentedsquashed and git diff instead of formatted patch
Comment #108
xjmExcellent! The new update hook looks spot on. Two minor things related to it:
These lines are outside the scope of our patch now, so we should drop this change.
I guess we need to change this summary now, since it's just renames permissions instead of migrating them.
Also, these lines:
These changes are also outside the scope of the patch, so let's revert them.
Comment #109
realityloop commentedminors fixed and kittens restored to life :)
Comment #110
realityloop commentedand re-added update function I accidentally removed
Comment #111
realityloop commentedbetter description for update hook
Comment #113
xjmThose fails are testbot issues. I've requested a retest, but maybe best to wait until tomorrow. :)
Comment #114
realityloop commentedMarking Needs Review as #111 passed once the testbot issue was resolved
Comment #114.0
realityloop commentedFormatting list.
Comment #114.1
realityloop commentedUpdated issue summary.
Comment #115
willvincent commentedSteps 1-4 work as expected, though there is a warning about whitespace in step 3: "warning: 1 line adds whitespace errors"
Step 5 does not work as expected.
Any role that has the 'view revisions' permission is able to view the revision list as expected, but the delete and revert operations are not showing up for anyone but my administrator user account.
Comment #116
xjmLooks like the patch needs more work, then. Untagging until #115 is addressed. It's documented in @drupleg's review in #95, too, so looks like it has persisted from earlier versions of the patch.
Comment #117
realityloop commentedRe #115
The revert display has been fixed, the delete links are only visible if the user has access to delete the node in question, I initally planned to override this requirement but have since thought of use cases where it's properly required.
With that in mind I have added the following description to the delete permissions:
Requires Delete own content or Delete any content to nodes of this type.
Updated patch to come shortly once I get tests passing again.
Comment #118
realityloop commentedtest still failing, the $node object seems to be either getting blown away in the test at line 385, or it's not accesible to the newly logged in $power_web_user.
Hoping I can get some insight from someone with more test writing experience to help me to get the test to complete.
Comment #120
realityloop commentedthis should have less fails
Comment #122
realityloop commentedComment #124
realityloop commentedComment #125
xjmThanks @realityloop! First off, this patch is pretty thorough already and I very much like the extensive test coverage. Detailed review follows, including both questions about the functionality and minor stylistic points that are probably originally from the existing code. (The latter cleanups would be a good novice task).
Since we have this in here, we probably also need to add upgrade path test coverage. (I know you are very excited!) Reference: http://drupal.org/node/1429136
Let's specify "for page nodes" in the comment, and give the map a more descriptive name than
$map1in both the test and the API function. Maybe$page_mapor something?I'm still not quite sure this is the expected behavior. Is this currently the case for "delete any revisions" as well?
This is totally unrelated to this patch, but it's bugging me and I want to make note of it: Why does administer nodes get AND-ed with the node access? Why is that the expected behavior? Shouldn't it be in its own "or"? Shouldn't administer nodes work regardless of node access? What happens elsewhere in the module?
Technically this change is out of scope, but I'm +1 because it's significantly more readable this way. ;)
"Related operations" is kind of strange and vague. Maybe "Tests node revision operations" or "Tests node revision CRUD operations"?
Needs an article ("Get the last node...").
I'd say "are properly reverted" and "are properly deleted" (I was a bit confused at first by the text).
We should probably use LANGUAGE_NOT_SPECIFIED rather than 'und' here.
Let's put at least the final argument on a separate line for better readability.
I'd clarify this a little, since it took me a good 5 mins. to understand what this test was doing (granted it is 6a). :P How about:
Checks that empty log messages are saved correctly in new and updated revisions.(Not positive it fits in 80 chars, so double-check.)
Why is this the expected behavior?
Scanning the code for this class, it looks pretty familiar. I assume it's based on the existing revision tests davereid and I worked on when we fixed that critical recently? (I did not actually open the codebase and read since it is before 6a.) ;) Two questions:
We should have articles in the inline comments ("an initial node," "the original node," "a revision," "a random title and body").
$content_adminor something.These changes seem out of scope and should be reverted.
We should be using the constant here, not its value. What's the justification for this change?
Let's say "global" rather than "any" here.
This assertion does not seem to be replaced with anything. What's the case for removing it?
t(). They appear both ways in the patch (and in the current codebase), but in the lines we are adding and updating, let's removet()from the messages for better performance and decoupling. (Note: Remove thet()on message texts only in the lines added or updated by this patch, not from any other lines in the file.) Reference: http://drupal.org/simpletest-tutorial-drupal7#tPhew! As I mentioned above, some of these are minor cleanups, so tagging as novice for cleaning up the stylistic points above. Please include an interdiff with any updated patch so realityloop and I can easily review the changes. Please also indicate the # for each of my points above that you address for clarity.
Comment #126
realityloop commentedSorry, I find it really hard to just do some of the suggestions.. so here is everything apart from:
#1 this will take some time to develop
#12 I'm note sure, this code existed in the original test
#13 not entirely sure how to do this
Comment #128
realityloop commentedoops php error, fixed
Comment #130
realityloop commentedreadded t() around needed sections, should pass now.
Comment #131
xjmThanks @realityloop! The patch looks much cleaner now. However, there are still a number of changes that are not related to the issue, which make the patch harder to review:
These changes (while correct) are not within the scope of the patch, and should be removed.
Comment #132
realityloop commentedComment #133
realityloop commentedforgot to change status
Comment #134
Zgear commentedI took pictures before and after the patch to see what changed and sure enough the revisions permissions were there after the patch :)
Before:

After:
I don't know what else you changed but it seems good to me, if you want anymore testing just say so, and specify what you want me to test :)
Comment #135
realityloop commentedZgear, if you think it's ready can you please mark the status as RTBC?
Comment #136
Zgear commentedSince I am not fully sure what the patch does (and its been a while since I looked at this issue) I don't think I am quite qualified to call this RTBC, sorry.
Comment #136.0
Zgear commentedUpdated issue summary.
Comment #137
naxoc commented#132: 880940-per-content-type-revision-controls-132.patch queued for re-testing.
Comment #138.0
realityloop commentedUpdated issue summary.
Comment #139
realityloop commentedPatch updated to apply on current core
Comment #141
lyricnz commentedArgument 1 passed to node_save() must be an instance of Drupal\node\Node, instance of stdClass given, called in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/node/node.test on line 280 and defined
This is because $updated_node isn't an entity
Comment #142
adellefrank commentedDrupal 7 module to add this functionality (until we all upgrade to D8), can be found as a patch to the D6 module at http://drupal.org/node/1211568
This is just a note for those of us who need this, but can't wait until the marvelous D8 is available. :)
Comment #143
realityloop commentedComment #145
realityloop commentedComment #146
xjmI removed some out-of-scope changes (attached). Patch is much smaller now. :)
@realityloop and I discussed this issue in IRC, and I think what this issue really needs is more tests. An upgrade path test, for starters, now that we have a process for adding them.
Then, I'd also like to see more functional tests. Review the following comments to see what needs additional coverage:
There should be test cases for some of the bugs described in some of these comments. Additionally, it would be good to get some really detailed manual testing steps that folks have done (for which permissions they configured, etc.) and codify the expected behavior in tests.
Additional manual testing for various combinations of permissions would also be good (not just for the upgrade path). Please document any manual testing done in the issue.
Comment #147
tstoecklerWe usually prefer single quotes.
$type_map is not added to $parameters anywhere, so it doesn't seem like the new permissions are acutally tested, even though the assertions are changed to say that.
Why is this needed?
I don't really grasp why this is needed. We should try to avoid stuff like this.
These are already in node_permissions() this should be dropped here.
You can leave out the curly braces around {$type}
Comment #148
jody lynnI added a test for the issue in #93. The test shows that the revision permissions for a specific content type work for that content type but not for another.
Comment #149
tim.plunkettComment #150
tim.plunkettSplit out the tests to prove they work.
Comment #151
smortimore commentedWorking on the clean-up points in #147
Comment #152
smortimore commentedAll issues in #147 have been addressed.
Comment #153
smortimore commentedUnassigning for review
Comment #154
tstoecklerThis is needed because we use the 'page' and 'article' node types, right? Is there any reason for that, or could we just as well use WebTestBase::drupalCreateContentType to create our own content type. That would definitely be more efficient than using standard profile.
I've read this a couple times now, and found a bit strange every time, but by now I am pretty certain that this should rather be "view all revisions". I'm not a native speaker, but "any" in this case just doesn't feel right. I might be wrong, of course.
Comment #155
tim.plunkettIn response to #154:
1) That's a possibility, but I don't know that it's a necessity.
2) You are correct. It could be "view all revisions" or "view any revision".
Comment #156
realityloop commented#154 changes applied and tests updated against current dev..
Fingers crossed
Comment #157
realityloop commentedtest patch added
Comment #158
realityloop commentedAddressed #146
Comment #159
realityloop commentedAdded description text to perms to aid in configuration, it was not obvious that certain permissions were only usable when you had other perms granted..
Examples:
-you need a "view revisions" perm for the content type before "revert/delete revisions" will be available via the UI.
-You need "edit" rights for the node in question before the "revert" link will appear on the revisions list
-You need "delete" rights for the node in question before the "delete" link will appear on the revisions list
Comment #160
realityloop commentedSomeone had added an newer update function, updated mine.
Added description text to perms to aid in configuration, it was not obvious that certain permissions were only usable when you had other perms granted..
Examples:
-You need a "view revisions" perm for the content type before "revert/delete revisions" will be available via the UI.
-You need "edit" rights for the node in question before the "revert" link will appear on the revisions list
-You need "delete" rights for the node in question before the "delete" link will appear on the revisions list
Comment #161
realityloop commented#160: drupal-880940-160-combined.patch queued for re-testing.
Comment #163
realityloop commentedchasing head
Comment #165
realityloop commentedAll related tests now passing locally
It's my bithday today, I'd really like to get this in!
Comment #167
dagmarComment #168
realityloop commented#167: drupal-880940-167-combined.patch queued for re-testing.
Comment #169
fabianx commentedThis is obviously wrong if the rest is using "{$action} all revisions"
Why the {}? This seems to rather make this fail then succeed.
I am afraid that this will probably need an update test as this introduced a bug not caught by a test ... :-/. (unless I am totally mistaken)
Besides that, this looks really good. I was able to understand the patch from bottom-to-top without looking at the issue summary :-).
Great job!
Comment #170
fabianx commentedAs per #169, and I am really sorry about that ... Correct me if I am wrong :).
Comment #171
realityloop commentedThanks for the review Fabianx, I'm more than happy to work on an update test if it is still required, but would appreciate some assistance/mentoring on how to go about that as I've never had to do one before.
In the meantime here is updated patch with the permission name fixed, the curly braces follow how things are done earlier in the .install file.
Comment #171.0
realityloop commentedupdated links to current patch
Comment #172
fabianx commentedI searched through node.install and only found curly brackets for and around "tables".
Your upgrade is broken, I am almost 90% sure about this.
And if that works, then this is a side-effect not because this is right ...
Comment #173
realityloop commentedThough cury braces does work properly in the way I'd done it in earelir patch, ie. inside double quotes, I checked with xjm and she said that it's not generally the way that it's done in core, so here is upated patch with concatenation used instead.
Thanks again for the review's Fabianx
Comment #174
fabianx commentedany ->all
Besides that, I'd say its RTBC.
Comment #176
realityloop commented#174 done.
Comment #178
realityloop commentedmarking needs review because I attached patches in wrong order, and testbot marks as needs work if the last patch failed (in this case it's supposed to)
Comment #179
fabianx commentedIs this an actual behavior change or had that been in core before like this that you needed view to edit / delete a revision?
Besides that:
Please be specific for all instances of description texts please include the real permission name, because else this was really confusing to me.
And judging by the code the comment seems to be wrong ...
I am not yet totally happy with these changes:
First the "administer nodes" being now independent from node_access('update') needs to be explained.
Second this needs at least () around the || block.
I would probably not change this behavior at all in this patch and rather just replace user_access('revert revisions') with user_access("revert $type revisions") || user_access('revert all revisions') for example.
Comment #180
realityloop commentedNo it's not a behaviour change, I've just added the descriptions to aid people when setting premissions.
I've updated the description to be much clearer, eg:
The second section you reference had been reordered and so that it is in the same order as the original code, and the brackets have been corrected.
Comment #181
fabianx commentedonce "administer nodes", once "Administer nodes"
Please choose one.
$type is not defined.
I would say:
"role requires permission to view revisions and ..."
Should be consistent with the above.
I think we are very very very close to RTBC (from me).
Comment #182
realityloop commentedPerm descriptions in both locations changed to:
and
Comment #182.0
realityloop commentedupdated info
Comment #183
thedavidmeister commented#182: drupal-880940-182-combined.patch queued for re-testing.
Comment #184
realityloop commented#182: drupal-880940-182-combined.patch queued for re-testing.
Comment #185
fabianx commentedI tested this again yesterday thoroughly and I can't find any other problems with this patch. Upgrade test also works.
=> RTBC
Comment #186
realityloop commented#182: drupal-880940-182-combined.patch queued for re-testing.
Comment #187
realityloop commentedchasing head
Comment #188
realityloop commentedupdated for entity test fail
Comment #189
realityloop commentedlest try that one more time, for some reason the last were 0 bytes
Comment #190
fabianx commented#189:
Only tests: FAILED: [[SimpleTest]]: [MySQL] 48,015 pass(es), 748 fail(s), and 130 exception(s).
Real Patch: PASSED: [[SimpleTest]]: [MySQL] 48,689 pass(es).
Comment #190.0
fabianx commentedupdate
Comment #191
realityloop commentedre-uploading (these are identical) as I can't click re-test on #189
Comment #192
realityloop commented#191: drupal-880940-191-combined.patch queued for re-testing.
Comment #193
webchickI have only been able to watch in awe all of these years as you've worked so hard on this little patch. :) Looks like this has all the right things: the feature, the test coverage, the upgrade function, etc. Therefore, I think it's finally time to get this sucker in!
Committed and pushed to 8.x. YEAH, REALITYLOOP!!!
Comment #194
lyricnz commentedPersistence!
Comment #196
larowlanNote this issue added non PSR-0 test class to NodeRevisionTest.php see #1885868: NodeRevisionsTest.php contains two classes, not PSR-0
So the new tests added by this issue *aren't* being run at the moment.
Comment #197
Shevchuk commentedAny chance of backporting to D7?
Comment #197.0
Shevchuk commentedupdate issue with current patch
Comment #198
reinaldoc commentedAny chance of backporting to D7?
Comment #199
liquidcms commentedWhy am is there no permission for creating revisions? I have been unable to find any configuration to disable certain role from seeing the "create new revision" checkbox.. so gave up and simply added:
$form['revision_information']['#access'] = false;
we don't need revisions anywhere on our site; yet still can't get rid of this.. :(