Before I start, thanks for such a great module!

This is similar but not identical to the problem reported in http://drupal.org/node/412952 . I am seeing the revision message twice, but unlike the problem reported above, the edit and publish options are NOT being repeated, only the material in the information box, e.g.:

* Displaying current, published revision of Elements, last modified by Ron House on 03/05/2009 - 17:02
* Displaying current, published revision of Elements, last modified by Ron House on 03/05/2009 - 17:02
Ron House March 5, 2009
Edit this revision | Unpublish this revision

I was going to try the bit of debugging code that tc60045 used in the other issue, but the line he modified seems to have disappeared in the current version.

The message is duplicated on urls like: example.com/node/3
It is NOT duplicated on urls like: example.com/node/3/revisions/3/view

Thanks!

Comments

rdeboer’s picture

Assigned: Unassigned » rdeboer

Thanks for your feedback Ron!
And good detective work too! Yes, as I went through a refactoring a few versions ago, it seemed to me that the original patch used by tc60045 was covered by a more generic construct, which I put in, but I may have been wrong!
On Monday I will check into the development snapshot a patch along the lines of the original idea and we'll run with that for a while and see how it works for people.
The reason why you're not seeing the controls repeated is that these used to live in the message box (not so attractive), but have since moved to the top of the content area, where they can be more easily themed.
The fact that the message is duplicated on URLs of a particular format is useful debug info -- thanks Ron, will get back to you.
Rik

rhouse’s picture

Thanks Rik, I appreciate your help. It is annoying when these subtle bugs happen, and they can be the hardest to get rid of. I got lost trying to follow the logic of how the message is generated, so I couldn't attempt to solve the problem myself.

I don't know if it is helpful, but the other permission-related modules I have are: module grants, nodeaccess. I do not have workflow.

Ron.

rhouse’s picture

Hi again, I've tried an interesting experiment, using two static variables to count how many times functions are executed. I did:

function revisioning_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
$args = arg();
static $count = 0; $count++;
...
drupal_set_message(_get_node_details($node, $count));
...
function _get_node_details($node, $count) {
static $count2 = 0; $count2++;
...
if ($is_current) {
$message = t('Displaying %current revision of %title, last modified by !author on @date ' . $count2 . ' ' . $count, $placeholder_data);
}

and I got this display on the page:

* Displaying current, published revision of Welcome, last modified by Ron House on 05/11/2009 - 15:48 1 3
* Displaying current, published revision of Welcome, last modified by Ron House on 05/11/2009 - 15:48 2 5

So revisioning_nodeapi is being called twice with op=alter, and that is causing two calls to _get_node_details.

I tried the following very crude fix, but it seems to work:

function revisioning_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
$args = arg();
static $count = 0;
...
if (module_grants_node_revision_access('view revisions', $node) && !$count++) {

This also possibly skips a second call to _theme_content_menu, and I don't know what the consequences of that might be. Hope this helps, Ron.

rdeboer’s picture

Thanks Ron,
Before we go ahead, I'd like to understand the specifics a bit more.
In particular, what is the content type of the node in question?
Is the Views module enabled?
On your system, what is the value of the $teaser variable, just before get_node_details() is called?
In the meantime I have checked into the repository new versions of Module Grants & Revisioning, which may just fix your issue.
Let us know.
Rik

rhouse’s picture

Hi Rik,
The content types on the site are standard: book, story, page. But a closer look reveals that it is only story, not book or page, that shows duplicate messages. Strange! I'll try the new versions before I explore your other suggestions, as it may be the problem is now fixed.
Thanks for your help!
Ron.

rhouse’s picture

Hi again Rik,
Tried the new HEAD version of revisioning. The duplicate messages have gone, but unfortunately two worse bugs have appeared:

1) Published content edited by my guest author role (which has edit revisions permission, but not publish or unpublish) when saved, immediately becomes the published version - i.e., without moderation.

2) The moderator's PENDING tab has vanished.

I am afraid the code is beyond me, so I can't help out to find the problem. Thanks for your help!
Ron.

Anonymous’s picture

Have you downloaded the latest Module Grants too ? They need to go as a pair This should fix both issues

EDIT: Then look for Administer Content menu item

rhouse’s picture

Thanks midkemia. That fixed the missing PENDING tab, but the problem that the guest author's changes are automatically published still remains.

The user interface of the changes is really brilliant though!

Also, although this is probably what it intended, I have lost a feature I need. I want the guest author to be able to see but not edit all unpublished content. The official current versions allow this, but the HEAD versions don't. We really need an "access unpublished content" permission, which, if granted should simply funnel all permission checks through the normal set of checks performed for published nodes. I don't know which module should solve this problem.

Cheers, Ron.

rdeboer’s picture

@RTH, #8

Hi Ron,
There's a new feature that we're experimenting with: Administer>>Site configuration>>Revisioning (admin/settings/revisioning). Check whether this is ticked -- it should NOT be for the behaviour you want.

What is possible also is that under Administer >> Content management>>Content types>>edit>>Workflow settings for the content type in question you've got "Published" ticked. It should be unticked if you don't want to publish upon creation.

Regarding viewing unpublished content... that's also an experiment to show editable content only under the "Not published" tab. In light of your experience, I think I'm going to revert this, unless anyone has a good reason not to.

Rik

Anonymous’s picture

Hi Rik, Ron

I must admit Ron has a scenario i had not considered and that is " I want the guest author to be able to see but not edit all unpublished content."

Ron, a question. You say see "but not edit all unpublished content", which i take to mean edit those where permission granted, but see all others unpublished?
Could you give a case scenario for a user needing visibility of unpublished content of other content types? I will help me understand, and can then incoorporate it into my thoughts as we progress

Are we talking a logged in user or anonymous ?

The way i had seen it was a user would be given edit rights to certain content types, which would be the ones they need to see. Any other content outside those right, they should use the site itself to find, as then the content will be formatted correctly for their viewing. Remember incorrectly formatted/ or unformatted content an easily be taken out of context.

The suggestion of a further permission "access unpublished content" holds merit

There are cases where restriction of whats visible to a role is need, and others where it may not matter. Though as I mentioned in one of the other threads, as the number of nodes grows, without some form of filtering it might become unusable, like the standard content page

Case
Say i have a website where i have a section suitable for "Adults only", would i want a "Junior editor" who normally deals with the teen section, to have visibility ? Throughout the site i may have content restricted by role, but I definitely wouldnt want that restriction removed in "Administer Content"

I definitly think we need a switch of some sor , either restricting to content types editable or exposing all

John

rhouse’s picture

Hi John, Thank you so much for taking the time out to try to get to the bottom of my problem!

I am setting up a site that will have guest authors writing posts, which I want to verify for content, html sanity, etc., before it goes live. The guest authors are friends whom I trust completely, so I want them to be able to see the whole site, but they are not as drupal-savvy as I, and I don't want them to accidentally do terrible things, which they could do with administer nodes permission. Essentially I want the system to give them the same access to unpublished content that it would give them to the same item if it were published, so they can get advance warning of upcoming articles etc. In other words, the idea is that with an "access unpublished content" permission, the system would do all the normal checks, except that it would ignore the (un)published status for these people. I do envisage that I might in future have guests whom I trust a little bit less, so if there were such a permission, I could invent another role that differed only in lacking that one permission.

I want to check articles before they go live, so when a guest edits or creates an article, the new version should remain unpublished until I vet it and publish it. (Guest author does not have publish or unpublish revisions permission, so it seems odd that the HEAD version of revisions lets their edited version go public, as that is an implicit publication of the edited copy and unpublication of the previous version.)

I think I see why we are on slightly different wavelengths: you are seeing the permissions as determined by the type of node, whereas I don't have content categories that mean anything much as far as security goes (although I do see that they could be created if necessary). The security here amounts basically to only two things: guests can edit only their own articles, and they cannot publish or unpublish. Everything else is open to them. Normal anonymous and authenticated users should only see published stuff, of course.

With your "adults only" scenario, yes, I think your assumptions are correct. The nodeaccess module seems to handle that scenario by allowing one to set up an adult node with special restrictions.

Hope that all makes sense, and thanks again.
Ron.

rdeboer’s picture

Hi Ron,
If the behaviour you see for the HEAD (development snapshot) is indeed what you describe, then we have a bad bug. But I can't reproduce it...
Have you tried my suggestions under #9 ?

I don't think I quite follow you with this "access unpublished content" permission.
The content access rights (view, edit, delete) are already independent of the publication status, aren't they?
Just make sure the "view revisions" permission is checked for the roles that need to view unpublished content and that it is unchecked for anonymous users.
Then you give your guest authros "create + edit own content" and "edit revisions" permissions, but you take away "publish/unpublish/revert revisions" and "administer nodes" permission.
Finally for yourself in the role of moderator give yourself "publish/unpublish/revert revisions" permissions and you should be on your bike.
Or so I would think....
But it's getting late, I'm getting tired, I may be missing something...

Rik

rhouse’s picture

Thanks Rik, I had somehow failed to notice your #9 (need new glasses I guess!). I have checked everything you mentioned there and in #12. I had granted guest "revert revisions" permission, but have unchecked it - problem still persists. I don't understand the difference between that and unpublish though.

"I don't think I quite follow you with this "access unpublished content" permission.
The content access rights (view, edit, delete) are already independent of the publication status, aren't they?"

I don't think so. Guest still cannot see unpublished content from other users. (But they can in the current stable release version.) Since other sites will not want what I want, I suspect this new permission is the only way to satisfy everyone.

So still two problems: (1) Guest edits own current published version, and the new edit becomes the current published, instead of waiting for moderation, and (2) Guest cannot see other users' unpublished content. If Guest creates a fresh story, it correctly remains unpublished and appears in moderator's pending tab.

If you are not getting this behaviour, could it be some conflict with nodeaccess, which is the only other permission-related module I have?

If I might suggest a usability improvement: Users withOUT (un)publish permission are most likely to be editing their own works, and "I created" seems the right default in Administer content, but users with (un)publish are likely site moderators who will want to see all pending content by default and are most likely to want "I can access". Even in my testing, I have been tripped up by that, spending time wondering where the guest article has gone, only to realise some time later that I am only looking at my own articles.

Again, many thanks for the great module,
Ron.

Anonymous’s picture

Ron

Its possible your publishing issue due to Configuration

go to Site Configuration> Revisioning

Ddisable Auto-Publish. This was added as If a user has Publish Revision rights it should not be hel d up in moderation. Especially as they can just make a few more clicks to publish it

rdeboer’s picture

@Ron, #13
The behaviour you want is definitely the behaviour I want (without having to introduce a new option/permission), so I'm scratching my head about what could be different between the current official release and the development snapshot. Will install nodeaccess and see if that module is raining on our parade.

Your suggestion about the default menu option depending on the publication rights is a good one. Not sure whether in drupal you can easily set the default dynamically, but will find out.

Glad to hear that despite the glitches you're getting some value out of Revisioning.
Rik

rdeboer’s picture

@Ron,
The original thread was about duplicated info messages.
Do these still appear in the development snapshot?
Rik

rhouse’s picture

Thanks John - already disabled, sadly.

One thought that occurred to me: after installing the HEAD versions, I ran update.php. Was that the right thing to do?

Ron.

PS [CORRECTED] More testing: It seems that if Guest edits her own UNpublished original, a new revision is created, also unpublished. But if Guest edits her own original after being published by moderator, the publication status (published) transfers to the new revision and her changes go into publication. I am intrigued enough to delve into the code again and see what more I can learn (every time I do it I am more impressed). I must say you guys sure have done a magnificent job thinking through all this stuff!

rhouse’s picture

I believe I have found the bug causing my main trouble. In _handle_edit, the code has:

       case 'presave': // called from start of node_save()
...
       else {
          // Save the vid for subsequent restore during 'update' op
          $node->original_vid = _get_current_revision_id($node->nid);
        }
        break;
      case 'update': // called from end of node_save(), after _node_save_revision()
        $node->revision = $node->original_revision;
        if (isset($node->original_vid) && $node->original_vid != $node->vid) {
          // Resetting node vid back to its originial value, thus creating pending revision
          db_query("UPDATE {node} SET vid=%d WHERE nid=%d", $node->original_vid, $node->nid);
        }

But case presave and case update are executed in two different calls to _handle_edit, so changes are not propagated through the $node argument, which has been called by value. I changed the call and formal parameters from:

    _handle_edit($node, $op); // 'prepare', 'presave', 'update'
...
function _handle_edit($node, $op) {

to:

    _handle_edit(&$node, $op); // 'prepare', 'presave', 'update'
...
function _handle_edit(&$node, $op) {

and it stopped automatically publishing Guest's edits to a published version. I think it has also stopped making gratuitous versions, but I need to do a thorough check.

Ron

rdeboer’s picture

Great detective work Ron!
I think you hit the nail on the head!
This code was indeed part of a refactoring I did on the development snap shot and I forgot to put the '&' in.

Strangely enough, after downloading the snapshot on my machine at home (a Mac), I don't have the problem!

What I did find though when trying to reproduce your issue, is an error in the SQL in the _is_pending() function. The word 'FROM' is missing from the query. This however, is an issue only when "Only when saving content that is not pending" is checked under the Workflow settings of the content type.
Will fix this on Monday.

The fact that gratuitous revisions have stopped may be because you've switched that radio button under Content management >> Content types >> edit >> Workflow settings back from "Every time content is saved" to "Only when saving content that is not pending" (which means that you would have had the SQL error)?

Rik

rhouse’s picture

Hi Rik, thank you.

The gratuitous revisions stopped also because of this change, as I never had that set in the first place.

[UPDATE: inserting your missing FROM fixes a second bug I had noticed - thanks!]

Ron

rhouse’s picture

Hi again Rik,

I have made another change that seems to make sense in the case where the "Every time content is saved" option is selected. At present, if Guest creates a node and then edits it, the revisions display says:

Saved 05/29/2009 - 17:16 by Karen pending moderation
Saved 05/29/2009 - 17:10 by Karen current revision (unpublished)

and the earlier version is flagged as current - which makes sense if current is published, but not if it isn't, as here, since the naive Guest is likely to start editing the "current" version, expecting to be editing their latest save. It is better in this case to make the latest version current, so the display reads:

Saved 05/29/2009 - 17:40 by Karen current revision (unpublished)
Saved 05/29/2009 - 17:10 by Karen archived

It turns out to be relatively easy to do this. Change:

      case 'presave': // called from start of node_save()
        $node->original_revision = $node->revision;
...
      case 'update': // called from end of node_save(), after _node_save_revision()
        $node->revision = $node->original_revision;
        if (isset($node->original_vid) && $node->original_vid != $node->vid) {

to:

      case 'presave': // called from start of node_save()
        $node->original_revision = $node->revision;
        $node->original_status = $node->status;
...
      case 'update': // called from end of node_save(), after _node_save_revision()
        $node->revision = $node->original_revision;
        if ($node->original_status && isset($node->original_vid) && $node->original_vid != $node->vid) {

Of course I am merely futzing around here, very grateful for the opportunity to learn to understand this snazzy code; you may well see some more elegant way to do it.

Ron.

rdeboer’s picture

Hi Ron,
Well you seem to find your way round the guts of the code, alright! Good stuff!

I see where you're coming from, but it would interfere with a second scenario: that of a previously published node as opposed to a node pending publication.
The definitions are a bit wishy-washy (because revision moderation was never designed properly in the drupal core), but this is what we're working with:

-- node pending publication: unpublished node with (at least) one revision newer (greater vid) than the current revision
-- previously published node: unpublished node whose newest revision is the current revision

[As an aside: when a node has only one revision we can't tell whether it's pending publication or was previously published -- we'll have to live with that for the moment; the code considers such nodes pending]

So your patch effectively turns a node pending publication into a previously published node, so it will no longer show up under "pending".

Rik

rhouse’s picture

Hi Rik,

"I see where you're coming from, but it would interfere with a second scenario: that of a previously published node as opposed to a node pending publication."

I wondered about that and tested it. AFAICT, that case continues to work in the present manner. Here is the revisions after two edits by Guest:

Saved 05/29/2009 - 19:23 by Karen pending moderation
Saved 05/29/2009 - 19:22 by Karen pending moderation
Saved 05/29/2009 - 17:43 by Karen current revision (published)

"So your patch effectively turns a node pending publication into a previously published node, so it will no longer show up under "pending"."

I don't think so. The extra check only prevents shifting the 'current' marker when there is no published node in the trail, it doesn't alter any tests for pending. I have entered three stories, one never published with only one edit (the original), one never published with two edits, and one which has edits after the published version, and all three show up in Pending. I can't find a case that the change changes, except the one it is meant to change.

Of course I don't really understand the subtleties of the various fields in $node, so I could be way off beam.

Ron.

rdeboer’s picture

Ron,
The example you give in #23 shows a published node, I'm talking about unpublished nodes only.

-- unpublished node with revision(s) newer than the current revision -> pending moderation
-- previously published node: unpublished node whose newest revision is the current revision -> unpublished

Nodes that are in the first situation will appear under the "Pending" tab, whereas nodes in the second case won't.
If you unpublish the node in your example (node remains pending) and then save a new revision (thus executing your code), you'll find that the node will no longer show up under the "Pending" tab (it will be under "Not published").
Rik

rhouse’s picture

Hi Rik,

Yes, I see what you mean. However, it raises a new question, how does the moderator proceed if he reads the revision, decides not to publish it as it stands, and tells the author to revise it? How does he remove it from Pending until it has been edited again? It seems that 'current' status is used to flag which revision has been checked by moderator (a newer one flags pending again) but with unpublished work, there doesn't seem to be a way for moderator to shift the current flag onto the one he has rejected. Publishing does it, but he doesn't want to do that. Also, by using current status in this way, when only a single revision (the original) exists, it must be current, so it is taken as pending. Even with a way to shift the 'current' flag, moderator can never get that article out of the Pending tray until a second revision is made. This is likely the most common case.

I apologise for letting this thread get so long and take so much of your time, but the module has subtlety and a fascination about it that just drags one in!

Also I think I forgot to answer your question about the duplicated messages - they seem to be fixed since the other bug got put right - thanks. And apologies for not sticking to one point in one thread!

Ron.

rdeboer’s picture

Version: 6.x-2.5 » 6.x-2.x-dev
Status: Active » Fixed

Also I think I forgot to answer your question about the duplicated messages - they seem to be fixed since the other bug got put right - thanks.

Great, Ron!
I' shall consider this one fixed then (until it rears its ugly head again -- haha!).
I have moved your latest question to a new thread #477682: Pending vs Rejected revisions and answered it there.
Rik

Status: Fixed » Closed (fixed)

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

crea’s picture

ekoaham’s picture

Status: Closed (fixed) » Active

Hi,

It appears that this bug has resurfaced. The issue appears to be the same one that the patch at http://drupal.org/files/issues/revisioning-HEAD_message_repeat.patch addressed.

I am running the following code base of relevant modules:
Drupal Core: 6.18
Revisioning: 6.x-3.11
ModuleGrants: 6.x-3.6
Tokens: 6.x-1.14

The behavior I see is that when I view a revision moderated node, the status message that displays above the node content is repeated twice. Each line reads "Displaying current, published revision of page Tips for Editing, last modified by admin on 09/27/2010 - 15:07".

Following the advice in the above referenced patch and related thread at http://drupal.org/node/536826, I decided to make the following change.

*** revisioning.module	2010-09-27 13:48:23.000000000 -0400
--- revisioning.module.orig	2010-09-27 13:43:07.000000000 -0400
***************
*** 373,377 ****
        if (!$teaser && $node->nid == arg(1) && // don't show msg on page with many nodes
          $node->revision_moderation && user_access('view revision status messages')) {
!         drupal_set_message(_revisioning_node_info_msg($node), 'status', FALSE);
        }
        break;
--- 373,377 ----
        if (!$teaser && $node->nid == arg(1) && // don't show msg on page with many nodes
          $node->revision_moderation && user_access('view revision status messages')) {
!         drupal_set_message(_revisioning_node_info_msg($node));
        }
        break;

Adding the extra arguments to drupal_set_message appears to have solved the problem and is also consistent with the drupal_set_message API call description.

I am not a Drupal expert and do not know if there are other ramifications to my change. I hope the maintainer and the other gurus will tell me if this fix is indeed the right answer.

Eko

ekoaham’s picture

Version: 6.x-2.x-dev » 6.x-3.11

Changing to revisioning code version 6.x-3.11

rdeboer’s picture

Yep -- I don't know how that slipped back in, but it did.
The patch you suggests is a quick way to fix it without side effects.
Will include in next release, which I hope to complete this weekend.

rdeboer’s picture

Status: Active » Closed (fixed)
akalata’s picture

Version: 6.x-3.11 » 6.x-3.13
Status: Closed (fixed) » Active

I'm still getting duplicate and/or conflicting status messages, depending on the state of the node.

- Displaying pending revision of chapter Recruiting, interviewing, and hiring, last modified by BakerMcKenzie on 08/29/2011 - 15:10
- Displaying current, published revision of chapter Recruiting, interviewing, and hiring, last modified by BakerMcKenzie on 08/29/2011 - 14:27
rdeboer’s picture

Status: Active » Closed (cannot reproduce)

The case in #33 is different because they're not repetitions of identical messages.
If the problem persist please log a new issue with a reproducable test-case stating all relevant configurations and steps leading to the problem.