tags:

views:

479

answers:

3

What is the most efficient way to go through and update every single node in a drupal site, to, for instance mechanically add tags? Drupal 6 has a shiny new batch API, but what to do in Drupal 5?

I started writing a script that keeps a pointer and then goes around all nodes on a cron, loads them and then saves them, but I wonder what else could be done.

A: 

hmm i'm not familiar with drupal 5's database structure, but if it's similar enough to drupal 6, you could just modify this all pretty easily by just working off the term_node table. it's a mapper of node id's to term id's:

term_node
- nid
- vid
- tid

nid is the node id of course, vid is the revision id, if you use revisions, and tid is the term id. terms are all stored in term_data

term_data
- tid
- name

are the more interesting columns. so if you already have existing terms, you can create a quick map of existing tid's, then add to whatever nodes you want in term_node. anyhow, being careless in this regard could possibly cause weird data issues, so i wouldn't suggest this approach unless you feel pretty comfortable with the raw database.

Owen
doing things on the db level is not something that I want to do - there is a lot more risk to mess everything up in a subtle way and then not notice until it's too late.
deadprogrammer
+3  A: 

I don't suggest working directly on the database level since some modules might want to update some other related tables. The most reliable and flexible way is to write a script to load, change and save nodes in a loop. You can also try using additional special modules for Drupal 5:

link0ff
+2  A: 

job_queue module http://drupal.org/project/job_queue