Tech Blog :: drush :: drush


Jan 21 '11 12:19pm

Drupal: Re-Sync Content Taxonomy from core taxonomy

I'm working on a major Drupal (6) site migration now, and one of the components that needs to be automatically migrated is taxonomies, mapping old vocabularies and terms to new ones. Core taxonomy stores node terms in the term_node table, which is fairly easy to work with. However, two taxonomy supplements are making the process a little more complicated:

First, we're using Content Taxonomy to generate prettier/smarter taxonomy fields on node forms. The module allows partial vocabularies to be displayed, in nicer formats than the standard multi-select field. The problem with Content Taxonomy for the migration, however, is that it duplicates the term_node links into its own CCK tables. If a node is mapped to a term in term_node, but not in the Content Taxonomy table, when the taxonomy list appears on the node form, the link isn't set.

Ideally, the module would have the ability to re-sync from node_term built in. There's an issue thread related to this - Keep core taxonomy & CCK taxonomy synced - but it's not resolved.

So I wrote a Drush command to do this. To run it, rename "MODULE" to your custom module, backup your database, read the code so you understand what it does, and run drush sync-content-taxonomy --verbose.

Warning: This code only works properly on *shared* CCK fields, that is, fields with their own tables (content_field_X tables, not a common content_type_Y table). Don't use this if your fields are only used by one content type.

[Embedded Gist - if it's not showing up, click here.]

The other taxonomy supplement that needs to be migrated is Primary Term. I'll be writing a similar Drush script for this in the next few days.

Update 1/27: There was a bug in the way it cleared the tables before rebuilding, should be good now. (Make sure to download the latest Gist.)

Jun 21 '10 10:50am

How to use the latest version of Pressflow Drupal with Drush Make

Pressflow is a performance-tuned, MySql-specific distribution of Drupal maintained by Four Kitchens. Drush Make is a way of automatically compiling the files needed to build a big Drupal site.

I posted this issue on Pressflow's Launchpad queue (after raising the question with their team at D4D):

I'm using Drush Make to build my sites and I'd like Pressflow to be the default core. It's easy to put projects[] = drupal in the make file and it gets the latest 6.x from drupal.org. But how do I get the latest Pressflow? Currently I have:

projects[drupal][download][url] = "http://launchpad.net/pressflow/6.x/6.16.77/+download/pressflow-6.16.77.tar.gz"
projects[drupal][download][type] = "get"

For every Pressflow upgrade, I have to change the path there manually, which mostly defeats the purpose of Drush Make (and is a barrier to using Pressflow). It would be great if I could simply put in http://launchpad.net/pressflow/6.x/6.x-latest.tar.gz and it would always fetch the latest version. Or better yet, have projects[] = pressflow instead of "drupal," but I don't want to press my luck...

Thank you!

David Strauss (creator of Pressflow) replied:

Two options:

* Use Drush Make's support for Bazaar, and use lp:pressflow
* Use this URL to our build server: http://files.pressflow.org/pressflow-6-current.tar.gz

Nice!