The Metatag module needs to be able to automatically import settings from Nodewords during its hook_install() implementation to make the upgrade process seamless. If possible this should be included with v1.0.


Original description

Once we have reached a 1.0 release, one of the immediate tasks to be done is to work on a migration script from Nodewords for D6 to Metatags. We'll likely have to try and support both 6.x-1.x and 6.x-2.x branches. Leaving as postponed for now as this is *not* a stable release blocker.

Files: 
CommentFileSizeAuthor
#8 1.JPG53.51 KBknarzer77

Comments

It's a separate though related issue, but I'm tempted to can the 6.x-2.x branch and just merge some of the functionality back into 6.x-1.x, without the clusterfsck :p

subscribe

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

Might I suggest that we approach this in a way that is similar to how the CCK module handles migrating d6 CCK fields to d7 fields. A dummy nodewords-7.x-1.x module can contain a nodewords_migrate submodule that will assist in migrating the data. Then uninstalling the nodewords module can cleanup old variables and database tables.

I am going to start working on this so please provide feedback if this feels like the correct approach or if there is a better way to handle this.

Title:Write upgrade path from nodewords to metatagsManual DB upgrade nodewords to metatags
Version:7.x-1.x-dev» 7.x-1.0-alpha3
Category:task» feature

I have been working on a project migrating a site from drupal 5 all the way to drupal 7. I have started working on a module to upgrade the nodeword data, based off the metatags_quick_import module. I haven't gotten a chance to finish a beta module but I did manage to write a quick script to move the data from the {nodeword} table to the {metatag} table.

Use this at your own risk. You should only use this if you are comfortable with php and mysql. I have only tested this for moving descriptions and keywords but it works in a pinch.

<?php
   
//collects the nodeword data
   
$query ='SELECT id, type, name, content FROM {nodewords}';
   
$result = db_query($query);
   
//collect and place nodeword data in array for metatag data
   
foreach ($result as $row) {
       
$nodewords_data[$row->id]['entity_type'] = $row->type;
       
$nodewords_data[$row->id]['data'][$row->name]['value'] = trim(strip_tags($row->content));
    }
 
//merg the nodeword data into the metatag data
 
foreach($nodewords_data as $entity_id => $metatag_data){
     
$id = (int)$entity_id;
     
db_merge('metatag')
      ->
key(array(
       
'entity_type' => $metatag_data['entity_type'],
       
'entity_id' => $id,
      ))
      ->
fields(array(
       
'data' => serialize($metatag_data['data']),
      ))
      ->
execute();
  }
?>

If you load this script into a pages body content with the php filter selected, then ping the page the data will be formatted and moved to the {metatag} table.

Hopefully this will help in some way.

Hi timbhowe,

thank you very much for your code snippet. I'm still waiting for a running upgrade path for nodewords to upgrade my sites from Drupal 6 to 7.

I tried your code an have 2 problems.

1: The column "type" is a number (like 5), but the column entity_type of meta tag is a string like 'node', so I have to convert:

if ($row->type == '5')
            $nodewords_data[$row->id]['entity_type'] = 'node';
        else
   ...
.

2. After that I run the code and see the descriptions and key words in my meta tag fields in this kind:
a:1:{s:5:"value";s:128:"...Text...";}

I don't know what a:1:{s:5:"value";s:128:" means.

Have you any idea what the problem is?

Jan

Title:Manual DB upgrade nodewords to metatagsWrite upgrade path from nodewords to metatags
Version:7.x-1.0-alpha3» 7.x-1.x-dev
Category:feature» task

Restoring proper issue details. Please leave them alone, as this is an issue set by the maintainer as a reminder to himself! Thanks. =)

Hey Jan,

I'll try to answer your questions the best I can but I have some of my own that could help me better understand your situation.

1. I don't know why you would have to convert the 'node->type'. It should be pulling the 'type' field out of the {nodeword} table which is stored as a varchar(25) and refers to the type of content the meta tag is associated. You may want to take a peek at you DB or your content types machine readable names.

2. What you are seeing is a serialized array of meta tags. The way the MetaTag module store the meta tag information is in a serialized multi-dimensional array in the 'data' field stored as a longblob in the {metatag} table. It is built like so:

array(2) {
    ["description"]=>
    array(1) {
      ["value"]=>
      string(100) "Drupal 7 with the metatag module is the best. YAH!"
    }
    ["keywords"]=>
    array(1) {
      ["value"]=>
      string(60) "metatags, drupal, drupal 7, awsomeness"
    }
}

I have only really worked with descriptions and keywords but the structure should hold true with other meta tag types supported.

I'm not really sure why you would be seeing the serialized array if you are using Drupal 7 and the Metatags module then when you go in to edit a node it should unserialized the data and place it in the correct field.

  • Are you using the most uptodate stable releases of Drupal 7 and the Metatag module?
  • Do you have the {nodeword} table in your DB with all the data?
  • Can you post the full code you ran?

I hope this helps but if you are still having issues let me know an I'll see what I can do.

Thanks
Tim

StatusFileSize
new53.51 KB

Hi Tim,

yes, i have the latest versions of drupal 6 / 7 and nodewords / meta tag.

I have (had) 3 drupal 6 sites, which I upgraded now to drupal 7 and from nodewords to meta tag with this script:

<?php
   
//collects the nodeword data
   
$query ='SELECT id, type, name, content FROM {nodewords} where name = '."'description' or name = 'keywords'";
   
$result = db_query($query);
   
//collect and place nodeword data in array for metatag data
   
foreach ($result as $row) {
        if (
$row->type == '5')
           
$nodewords_data[$row->id]['entity_type'] = 'node';
        else
            continue;
       
$s  = trim(strip_tags($row->content));
               
// trim the right tags
       
$pos = strrpos($s, '";}');
        if (
$pos > 0)
        {
           
$s = substr($s, 0, $pos);
        }
               
// trim the left tags
       
$pos = strrpos($s, '"');
        if (
$pos > 0)
        {
           
$s = substr($s, ($pos+1));
        }       
   
$nodewords_data[$row->id]['data'][$row->name]['value'] = $s;
   
// echo $s;
   
}
 
//merge the nodeword data into the metatag data
 
foreach($nodewords_data as $entity_id => $metatag_data){
     
$id = (int)$entity_id;
     
db_merge('metatag')
      ->
key(array(
       
'entity_type' => $metatag_data['entity_type'],
       
'entity_id' => $id,
      ))
      ->
fields(array(
       
'data' => serialize($metatag_data['data']),
      ))
      ->
execute();
  }
?>

In the attachement you can see a screenshot of my nodewords table.

Jan

I have posted a potential starting point here: #1434756: Potential starting point

I vote to officially get behind the Metatag Migrate module. To that aim I've requested to be made a co-maintainer.

Status:Postponed» Active
Issue tags:+D7 stable release blocker

There appears to be some working code to try out, and it now includes a Drush command, I think we should try this out and merge it in as a submodule for doing the migration. Dave, whaddya think?

Assigned:Unassigned» DamienMcKenna

Going to work on it this week.

I've imported the code from AntoineSolutions and drupalninja99 (#1434756: Potential starting point) and pushed it up as the nodewords_migrate branch, I'll continue to work on it there.

Can we have a separate project for nodewords_migrate? I think that would be easier.

I want to have it included with either Nodewords or Metatag to make it easier for most people - I decided to not include it in Nodewords to avoid people thinking there'll be a D7 version, which meant it had to go in Metatag.

Status:Active» Needs work

While I understand the need to keep the core module clean, I strongly feel that the upgrade should be as seamless as possible, thus the upgrade should be triggered automatically upon installation.

@DamienMcKenna Where do you stand with your progress on getting this going and what kind of ball park time frame are you looking at to have something usable?

I ask because I have a handful of sites I plan to upgrade from D6 -> D7 this winter (2012-2013) and desperately need the ability to easily migrate the metatag info. I keep holding out in hopes that this will be available but would like to have an idea on the time frame so I have a better idea of what I need to do for the upgrade.

Thanks!
Phil

@philsward: A reasonable question. My #1 goal has been to make Metatag stable and then deal with migration issues; we're close to having Metatag completely stable, so I'm hoping in November to do the upgrade paths for Nodewords & Page_Title.

@DamienMcKenna Sounds good! Thanks!

Hopefully not hijacking the thread too much, but what's the current advised course of action? I've a D6 site that I don't know what to do with in regard to this module. Most other stuff is done and I'd like to push it live but naturally don't want to castrate my SEO work. TIA.

Title:Write upgrade path from nodewords to metatagsUpgrade path: Nodewords

Issue tags:+upgrade path

Tag.

Component:Miscellaneous» Code
Assigned:DamienMcKenna» Unassigned

FYI the sql code worked for my Drupal 6 to 7 nodewords to metatags upgrade (it populated the metatag table) BUT and a big BUT the code does not populate the language field of the metatag table and thus when viewing a page all the meta tag desc and title fields are blank.

I simply populated the language field with the letters "ind" (it means undefined I think) for all records and now it works. Perhaps some boffin can add this to the SQL code :)

Hi, Undefined has the letters 'und'
Greetings, Martijn

FYI I'm going to be working on this over the next week.

The first decision is: leverage the Migrate module, or just built something custom? Using Migrate means that we'd have roll-back ability, and Drush integration, but it (obviously) adds a dependency. I'll look into it.

Thanks DamienMcKenna! I am just starting this migration and was planning to script the migration. However, do you have any idea how long this will take to get something we can test?

I'm aiming to have something working next week.

A presentation from Ken Rickard on using Migrate to import content: http://2011.drupalcampatlanta.com/session/migrating-data-drupal-7/

Hi,

Any progress in this field please?
Would be great to be able to migrate Nodewords metatags finally into Metatag!

greetings, Martijn

Hi,
@DamienMcKenna is this the thread which have to be followed to get this upgrade path rocking: http://drupal.org/node/1434756
Is it ok to use that tar. module (Nodewords_Migrate: http://drupal.org/node/1434756#comment-6077988)?
Greetings, Martijn

I've added a new branch so we can work on the upgrade path: 1281138-nodewords

See: http://drupal.org/node/1434756#comment-7443854 I am stuck with current code..
Thanks for working on this!
Greetings, Martijn

FYI I reverted my local install to use Migrate 2.5 and was finally able to get it to at least register on the Migrate Status page / drush command.

Hi Damien, Very curious to a solution to get Nodewords 1.x to Metatag (Nodes/Terms, etc). Thanks for updating.
greetings, Martijn

Hi Damien,
Can I test the upgrade already? If so, how can I download the branch 1281138-nodewords?
The upgrade of Nodewords to Metatag for nodes (1000+) and terms (100+) is the only thing stopping me for being able to migrate my site from D6 to D7.
Thanks a lot for your effort in advance.
greetings, Martijn

@Summit: The upgrade script doesn't work yet, I've been too busy over the past two weeks to continue working on it.

Hi @Damien, appreciate the update, still looking forward to test for you.
greetings, Martijn

I would also like to test the upgrade path.

I am also interested in testing the upgrade path.

Hi @Damien, Any progress please?
I will be away from next sunday until mid august. Hopefully in mean time you are able to move forward.
greetings, Martijn

In the interest of getting a 1.0 release out sooner, I'm taking this off the list of required features, but will hopefully be able to follow up Really Soon After with maybe v1.1 that includes it.

Begone, unwanted issue tag.

Hi, sorry to hear that about 1.0 wished it got in, but good it will be in the very soon after this 1.1 version.
Difficult to update site from 6 to 7 without this...

greetings,
Martijn

In hindsight, I think it'd be fine to do this as a Drush command.

Hi Damien, If that is the fastest to get to this ok.
Greetings, Martijn

I used the module given here https://drupal.org/node/1434756#comment-5839952 and followed these steps. The migration process was smooth. However, I don't see the metatag settings in node edit, I can see them in Drupal 6 site. Also I compared the page source in Drupal 6 and Drupal 7. The dcterms.date and revisit-after meta tag was missing in Drupal 7 page source. I had metatag dublin core module enabled.

I will try to find out the bug in this module. Other alternatives is to try migrate module, I saw that metatag module provides migrate module integration.

Also waiting for nodeword as well as page title upgrade path to metatag.

My Drupal 6 site was using nodewords and nodewords_pagetitle module. I needed to upgrade nodewords and page titles to one metatag. I followed these steps for migration. Hope this helps.

- Enable metatag module and metatag views module (if required)
- Apply this patch and update database. This will migrate page titles to metatag
- Use this module and enable it. Follow these steps for migration. This modified module will make sure that previously set title metatag is not lost. Also it will upgrade metatag for node, user and taxonomy term entity types. Frontpage metatags will be migrated as well.

Thanks @HyperGlide and @jantoine for their works.

I was getting this kind of error

Missing argument 4 for metatag_metatags_save()

in both database update and migrating nodewords to metatag. I guess this is a bug in metatag module's function metatag_metatags_save($entity_type, $entity_id, $metatags, $language)
I think changing this to metatag_metatags_save($entity_type, $entity_id, $metatags, $language = NULL) will fix the warning messages. I will test this and provide a patch in metatag module.

Hi @subhojit777. DId you also migrate metatag keywords and description?
Greetings, Martijn

@Summit Yes, all metatags that you were using in Drupal 6 site

@subhojit777 thanks!, I see here the module where you are referring to right? https://drupal.org/node/1434756#comment-7863375 Maybe connect these issues tighter? Greetings, Martijn

@Summit I have already done that here. Also the module mentioned https://drupal.org/node/1434756#comment-7863375 is bit buggy :-p was not tested properly. I will soon upload the proper module and upload it there. Will notify that in this issue queue.

@Summit here is the correct module https://drupal.org/node/1434756#comment-7868769

Hi @subhojit777, I have not worked with migrate yet. It will take some time to learn I think. Thanks for your update!
Greetings, Martijn

Issue summary:View changes

Clarified the purpose of the issue.

'After using nodewords_migrate module and try to migrate meta tags ,
I got this error

"Recoverable fatal error: Argument 3 passed to metatag_metatags_load_multiple() must be an array, none given, called in sites\all\modules\metatag\metatag.module on line 337 and defined in metatag_metatags_load_multiple() (line 351 of sites\all\modules\metatag\metatag.module).

Please hellp me to sought out this issue.

Thanks

Issue summary:View changes

Hello from Drupal's GSoC 2014 team. Google Summer of Code (GSoC)? - an annual program for university students organized by Google with projects managed by open source organization mentors such as us (Drupal!).

We're currently browsing the issue queue looking for projects. Do you think this issue/project is worth a student spending a summer on it and being paid by Google? If so, are you interested in mentoring the student? Learn more about Summer of Code and how to get involved at links below. We're submitting our Summer of Code application to Google in just over 24 hours and looking for last minute ideas. Please respond quickly if you're interested.

Group to join - https://groups.drupal.org/google-summer-code

Ideas for projects for Summer of Code 2014 - https://groups.drupal.org/node/404778

GSoC Homepage http://www.google-melange.com/gsoc/homepage/google/gsoc2014

Google's Summer of Code 2014 Announcement - http://google-opensource.blogspot.com/2014/02/mentoring-organization-app...

@Slurpee: Is it too late to nominate this task for the 2014 effort?