Drupal Mavens,
On a site with about 600 nodes I need to change the node author on about 300 of them. It's very straightforward in that everything that is written by uid="2" needs to change to uid="4".
I was about to write a simple sql query to implement in phpMyAdmin but thought I'd come here first (*and* back up the db).
I'm seeing uid in two tables: node and node_revisions. Does UID exist anywhere else?
Also, would I be fine with just changing it in the node_revisions table?
Thanks,
Shai
Also, would I be fine with just changing it in the node_revisions table?
as far as I know, this would be fine, but I look forward to other responses, because I sometimes do this sort of thing directly in the DB. While generally it works, sometimes it can have side effects. In this case, it seems pretty safe.
F
Quoting Shai Gluskin shai@content2zero.com:
Drupal Mavens,
On a site with about 600 nodes I need to change the node author on about 300 of them. It's very straightforward in that everything that is written by uid="2" needs to change to uid="4".
I was about to write a simple sql query to implement in phpMyAdmin but thought I'd come here first (*and* back up the db).
I'm seeing uid in two tables: node and node_revisions. Does UID exist anywhere else?
Also, would I be fine with just changing it in the node_revisions table?
The safer method is to node_load(), change the data and then node_save(). This gives any contrib modules you have a chance to do anything necessary.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
Earnie,
You'd run node_save() in devel's drupal execute block? Does it resave every single node?
Thanks,
Shai
On Tue, Aug 5, 2008 at 3:07 PM, Earnie Boyd earnie@users.sourceforge.netwrote:
Quoting Shai Gluskin shai@content2zero.com:
Drupal Mavens,
On a site with about 600 nodes I need to change the node author on about
300
of them. It's very straightforward in that everything that is written by uid="2" needs to change to uid="4".
I was about to write a simple sql query to implement in phpMyAdmin but thought I'd come here first (*and* back up the db).
I'm seeing uid in two tables: node and node_revisions. Does UID exist anywhere else?
Also, would I be fine with just changing it in the node_revisions table?
The safer method is to node_load(), change the data and then node_save(). This gives any contrib modules you have a chance to do anything necessary.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
-- [ Drupal support list | http://lists.drupal.org/ ]
On Tue, Aug 5, 2008 at 1:40 PM, Fred Jones fredthejonester@gmail.com wrote:
You'd run node_save() in devel's drupal execute block? Does it resave every single node?
No, it does one at a time--you would have to write a loop with PHP to load and then save each node.
It would be something like the snippet provided here: http://pingv.com/blog/greg/200611/automatically-publishing-and-setting-a-ter...
That said, node_save doesn't let all modules take action and the super best way to do this is with drupal_execute following some of the tips in this mega thread: http://lists.drupal.org/pipermail/development/2008-March/029148.html
So, you have three options. Ranked in order from simplest to most difficult which is also the order from most likely to cause problems to least likely to cause problems: 1. Updating the DB directly 2. Using node_load/node_save as in the snippet from pingv.com that I linked above 3. Using the drupal_execute method as mentioned in that listserv thread
If this were up to me I'd probably change 3 or 4 nodes in the database and then look at them and see if there are any issues. If that works, do it for all of them. If not...
Cheers, Greg