Download & Extend

Turn on the Revision Moderation flag for previous nodes

Project:Revision Moderation
Version:5.x-1.0
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Is there a quick way to set all node of a give type so that their "Revision Moderation" flag is turn on? I just imported about 250 links node (a custom CCK node I made) but I just found out that I did not set that flag on those imported nodes. Is there a small PHP script I could run as a page node or some other method that would allow me to set retroactively this flag?

Thanks for your help.
Marc

Comments

#1

Do you have direct access to the database. Some SQL might cheer you up.

#2

I had to do the same thing. I had the database module installed so I could run a query directly on the database. I had a little trouble getting the syntax for nested queries so I did a cut and paste of

select nid, 1 from node

and did a find and replace to put it into (nid,1) format, and just copied that into:

insert into revision_moderation values (nid1, 1), (nid2, 1), ... (nidn, 1)

Worked like a charm.

Mike

#3

Ah. In the future, I think you could do this a little easier with:

INSERT INTO revision_moderation (nid, revision_moderation) SELECT nid, 1 FROM node;

Kind of a funky syntax, but it should be cross-database compatible, unlike the multiple value pair syntax: http://dev.mysql.com/doc/refman/5.1/en/ansi-diff-select-into-table.html

#4

Status:active» fixed

#5

Status:fixed» closed (fixed)

#6

Here is an error-resistant version of the code in #3:

DELETE r.* FROM revision_moderation r JOIN node n ON r.nid = n.nid WHERE (type = 'page' OR type = 'story' OR type='book');
INSERT INTO revision_moderation (nid, revision_moderation) SELECT nid, 1 FROM node WHERE (type = 'page' OR type = 'story' OR type='book');

The first line deletes all revision_moderation flags for nodes of type page, story, or book. The second line re-inserts a revision_moderation=1 flag for all nodes of these 3 types. This will force all nodes to use revision_moderation.

The version of the code in #3 might give an error if you have some nodes in your database that have been created with a revision_moderation flag already. You might get an error like "ERROR 1062 (23000): Duplicate entry '252' for key 1".

The SQL above has only been tested on MySQL and may not run on other databases.

What types have revision moderation enabled by default?

This query looks in the variable table to check the node_options_TYPE settings and return a list of types with revision_moderation enabled by default.

SELECT SUBSTR(name,14) AS type FROM variable WHERE name LIKE "node_options_%" AND value LIKE "%s:19:\"revision_moderation\";%";

What types have at least one node with revision moderation enabled?

This query looks in the revision_moderation table to see what node types have one or more revision_moderation=1 flags.

SELECT DISTINCT n.type FROM node n RIGHT JOIN revision_moderation r ON n.nid = r.nid WHERE r.revision_moderation=1;