I wanted to create a view that lists all live nodes. I selected the filter "Node Revision: Content Moderation state" and the value "live". None of the live nodes showed up. I set the value to "none" and then some of the live nodes showed up... I'm guessing this has something to do with me enabling the module after some nodes were already created

Problem 1 - I had a look at the database: seems like the live state for nodes/revisions is not saved in the table "content_moderation_revision_state". And views uses this table for the filter. I haven't looked at the code to try and fix this as I'm not sure if this is a bug, or by design...

Problem 2 - Nodes created before enabling the content moderation module never show up in the view. Even after editing them.

CommentFileSizeAuthor
#9 content_moderation_i18n_tnid_sync_fix.patch950 bytesweseze

Comments

eugenmayer’s picture

Status: Active » Postponed (maintainer needs more info)

The live state is saved in the content_moderation_revision state. Existing nodes, which existed, when the module has been activated, have no entry in the live table, thats correct. That rather a feature request

i have the filter working on my installation but only used it for non-live states, so maybe there is a problem.

- Ususaly when a node is in the transaction aprove->live a entry will be created in the content_moderation_revision_state table. if that does not happen (did happen for me), this is a bug
- for existing nodes, which do not yet have been moderated and set to live (eventhough they are live already, but no transaction happened) this state is not yet there.

AFAIK this is a feature request:

Create live state for all exisiting nodes when activitatin content_moderation.

Please confirm if i got that right :)

weseze’s picture

yes and no :)

scenario 1:
node created before installing the module is not in the table: there should indeed be a feature request for this

scenario 2:
node created before installing the module and then edited and set to live afterwards. These nodes have the status "none" in the table "content_moderation_revision_state" instead of "live".

scenario 3:
node created after installing the module and set to live. These nodes also have the status "none" in the table "content_moderation_revision_state".

So I think there is a bug in my install. Or can I safely use "none" as "live"?

eugenmayer’s picture

Well, only the last "live" version has the "live" state in that table, not all yet "live" versions. Those informations are then saved in the history table. I can see a fairly good point in list "all live revisions of a node". But this sounds more like a feature request once again.

scenarion 1:
Please open a feature request :)

scenario 2:
Iam confused because you talk about nodes, not revisions of those. Please rephrase so i can better follow you. In general the _last_ live-revision has the "live" state in that table. "old live" versions have the "none" state actually, but see my first sentences for this issue.

scenario 3: same here, could you use "revision" and redeclare? :)

Thanks for the input!

weseze’s picture

both scenario 2 and 3 I'm talking about revisions of the node. Sorry for the confusion :)
So if I have a look at the table, none of the revisions listed there have a live state, even if they really are live revisions.

eugenmayer’s picture

Title: Views: Content Moderation State filter not working » "content_moderation_revision_state not correctly updated

Well that needs some investagation. Did you try this on a clean D6.16 installation with content_moderation installed?

What kind of DB do use? Mysql or postgresql? do you have any errors in the watchdog

weseze’s picture

it is a clean install of Drupal 6.16 on a mysql database. The watchdog doesn't contain any errors...

Can I debug (put some print_r() or something) somewhere to determine what is going wrong?

eugenmayer’s picture

Status: Postponed (maintainer needs more info) » Needs work

Well now its time for me to get some more debug details. Guess you have to wait until i have fixed it, maybe next week, pretty busy this one.

Anyway thanks for all the informations

senthil.na’s picture

Hi i got a small hint, the INSERT query is not used for tables content_moderation_node_history, Browse content_moderation_revision_state
May it will be useful to debug..

weseze’s picture

StatusFileSize
new950 bytes

sorry, posted in wrong topic. Can I delete my post?

eugenmayer’s picture

I guess not :) dont worry, happens

weseze’s picture

Status: Needs work » Needs review

I changed the query in the function _content_moderation_set_live($vid, $nid) and it seems to be storing the live state correctly now. I don't know if there are going to be other problems with this change.
Changed line 139 in content_moderation.workflow.inc from

db_query('UPDATE {content_moderation_revision_state} SET state = "none" WHERE nid = %d AND state="live"', $nid);

to

db_query('UPDATE {content_moderation_revision_state} SET state = "none" WHERE nid = %d AND state="live" AND vid <> %d', $nid, $vid);
eugenmayer’s picture

Status: Needs review » Fixed

Your fix is perfectly correct.

The problem was

/*
 * Implementation of hook_form_submit
 */
function content_moderation_change_state_form_submit($form, &$form_state) {
  global $user;

  $node = $form_state['values']['node'];
  $curstate = $form_state['values']['oldstate'];
  $nextstate = $form_state['values']['nextstate'];
  $comment = $form_state['values']['comment'];

  // Change the revision state.
  _content_moderation_update_revision_state($node->vid,$node->nid,$nextstate);

  // If the state is live, change the current live version.
  // TODO: the "final" state maybe should not be hardcoded later.
  if($nextstate == 'live') {
    _content_moderation_set_live($node->vid,$node->nid);
    drupal_set_message(t("This revision !vid has now been published as the new live version.", array('!vid' => $node->vid)));
  }

Here, first the new revision is set live and then after that, ALL live revisions are set to none, including our new revisions. So your login included "remove all live states except the current new created one", which is identified by the vid.

Thanks for the contribution. That fix will be inlcuded in 1.3

eugenmayer’s picture

Status: Fixed » Closed (fixed)