Given that Nodewords now includes the functionality of Nodewords_ByPath, shouldn't it also have an update script to migrate the latter's settings?

Comments

Version:6.x-1.x-dev»

I'll build an update script over the weekend and will post it for prosperity.

Status:Needs work» Active

Something to start from:

<?php
/**
* Implementation of hook_update_N().
*/
function mymodule_update_6101() {
 
$ret = array();
 
// Migrate nodewords_bypath data.
  // Build the query.
 
$q = db_query("SELECT rules.id, rules.name, rules.path_expr, url.src internal_url, tags1.meta_value description, tags2.meta_value keywords
    FROM {nodewords_bypath_rules} rules
    INNER JOIN {nodewords_bypath_tags} tags1 ON rules.id=tags1.rule_id AND tags1.meta_tag='description'
    INNER JOIN {nodewords_bypath_tags} tags2 ON rules.id=tags2.rule_id AND tags2.meta_tag='keywords'
    LEFT OUTER JOIN url_alias url ON rules.path_expr=url.dst"
);
 
// Loop over all of the records.
 
while ($record = db_fetch_object($q)) {
   
$type = FALSE;
   
$id = FALSE;
   
$tags = array();
   
// See if this is a taxonomy-term path.
   
if (empty($record->internal_url)) {
     
$ret[] = array('success' => TRUE, 'query' => "Couldn't migrate Nodeword_byPath records for '{$record->name}' with path '{$record->path_expr}'.");
    }
    else {
     
// It was a node path.
     
if (substr($record->internal_url, 0, strlen('node/')) == 'node/') {
       
$type = NODEWORDS_TYPE_NODE;
       
$id = (int) str_replace('node/', '', $record->internal_url);
      }
     
// It was a taxonomy/term path.
     
elseif (substr($record->internal_url, 0, strlen('taxonomy/term/')) == 'taxonomy/term/') {
       
$type = NODEWORDS_TYPE_TERM;
       
$id = (int) str_replace('taxonomy/term/', '', $record->internal_url);
      }
     
// See if the description field was present.
     
if (!empty($record->description)) {
       
$tags['description'] = array('value' => $record->description);
      }
     
// See if the keywords record was present.
     
if (!empty($record->keywords)) {
       
$tags['keywords'] = array('value' => $record->keywords);
      }
     
// If a recognizable type was found, process it.
     
if ($type && $id && count($tags)) {
       
// Save the record.
       
nodewords_save_tags($type, $id, $tags);
       
$types = implode(', ', array_keys($tags));
       
$ret[] = array('success' => TRUE, 'query' => "Migrated Nodewords_byPath {$types} record(s) for '{$record->name}'.");
       
// Remove the unwanted records.
       
$ret[] = update_sql("DELETE FROM {nodewords_bypath_tags} WHERE rule_id={$record->id} AND meta_tag IN ('description', 'keywords')\n");
       
// Only remove the main rules record if there are no remaining tags.
       
if (!db_result(db_query("SELECT COUNT(meta_tag) FROM {nodewords_bypath_tags} WHERE rule_id=%d", $record->id))) {
         
$ret[] = update_sql("DELETE FROM {nodewords_bypath_rules} WHERE id={$record->id}\n");
        }
      }
    }
  }
 
// Clear the page cache so the node changes show.
 
cache_clear_all('*', 'cache_page', TRUE);
  return
$ret;
}
?>

Update: fixed the tags arrays which needed to have a nested array with the tag's value.

Status:Active» Needs work

Status:Active» Needs work

Thanks for writing the code, and helping with this.

I am not actually sure if the code should be put on an update function, or if the code should be added in the tools page I am thinking to write. The pro of putting it in a tools page is that the users would be able to change the settings for the code, and the way the code works.

In any cases, the code you wrote is a good start, and it is all the needed code (except some changes that should be done to adapt it to the eventual tools page). I appreciate your help.

Glad to be able to help, hope others can make use of it.

Project:Nodewords: D6 Meta Tags»
Component:Database schema» Third-party integration

I am moving the report to the project containing the interested module.

Project:» Nodewords: D6 Meta Tags
Version:» 6.x-1.x-dev
Component:Third-party integration» Code

This module is not maintained anymore. This feature should be implemented in Nodewords.

The usage of Nodewords by Path has significantly dropped since this issue was filed (16 months). Previously it has reached a usage of around 2000 users, but now it's right around 600 users. Is this still worth it?

http://drupal.org/project/usage/nodewords_bypath

I've offered to take over the Meta Tags by Path module to provide an official upgrade path to Nodewords: #1664280: Offer to become co-maintainer

Status:Needs work» Active

I've been granted co-maintainer access and am going to work on the upgrade path from both sides: #1673754: Deprecate Nodewords_ByPath in favor of Nodewords

I've updated the module's status, now to do an upgrade path.