Community Documentation

Migrate from Nodewords 6.x-1.6 to 6.x-1.7

Last updated April 7, 2012. Created by gabrielu on December 11, 2009.
Edited by shamio, silverwing. Log in to edit this page.

Hey,
I recently experienced problems from updating to a new version of nodewords and removing the nodewords_by_path module. Looks like the format in the DB for nodewords table has changed to the serialized format. The old meta information was still in the database, but it was not recognizable since the format was plain.

So I made a quick script to port the meta tags (abstract, copyright, keywords and description) from one format to another:

Create a page with PHP content and write the following: (it's recommended to backup the database first)

<?php
// PHP Code
$result = db_query("SELECT * FROM nodewords n WHERE ( n.name='copyright' OR n.name='abstract' OR n.name='keywords' OR n.name='description' ) AND n.content NOT LIKE 'a:%{%}';");
while (
$item = db_fetch_object($result)) {
    unset(
$new_content);
   
$new_content = array('value' => $item->content);
    
$data = array(
       
'mtid' => $item->mtid,
       
'name' => $item->name,
       
'content' => serialize($new_content) // looks like drupal_write_record() doesn't serialize this, so I do it manually
     
);
     
   
drupal_write_record('nodewords', $data, 'mtid');

  }
?>

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Contributors, Programmers, Site administrators

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here