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

DamienMcKenna’s picture

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

jenlampton’s picture

subscribe

jantoine’s picture

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.

timbhowe’s picture

Title:Write upgrade path from nodewords to metatags» Manual 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.

knarzer77’s picture

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

greg.harvey’s picture

Title:Manual DB upgrade nodewords to metatags» Write 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. =)

timbhowe’s picture

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

knarzer77’s picture

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

jantoine’s picture

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

DamienMcKenna’s picture

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

DamienMcKenna’s picture

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?

DamienMcKenna’s picture

Assigned:Unassigned» DamienMcKenna

Going to work on it this week.

DamienMcKenna’s picture

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.

drupalninja99’s picture

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

DamienMcKenna’s picture

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.

DamienMcKenna’s picture

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.

philsward’s picture

@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

DamienMcKenna’s picture

@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.

philsward’s picture

@DamienMcKenna Sounds good! Thanks!

NikLP’s picture

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.

DamienMcKenna’s picture

Title:Write upgrade path from nodewords to metatags» Upgrade path: Nodewords
DamienMcKenna’s picture

Issue tags:+upgrade path

Tag.

DamienMcKenna’s picture

Component:Miscellaneous» Code
Assigned:DamienMcKenna» Unassigned
guysaban’s picture

ThaboGoodDogs’s picture

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 :)

Summit’s picture

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

DamienMcKenna’s picture

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.

j.mapping’s picture

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?

DamienMcKenna’s picture

I'm aiming to have something working next week.

DamienMcKenna’s picture

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

Summit’s picture

Hi,

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

greetings, Martijn

Summit’s picture

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

DamienMcKenna’s picture

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

Summit’s picture

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

DamienMcKenna’s picture

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.

Summit’s picture

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

Summit’s picture

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

DamienMcKenna’s picture

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

Summit’s picture

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

lunk_rat’s picture

I would also like to test the upgrade path.

hockey2112’s picture

I am also interested in testing the upgrade path.

Summit’s picture

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

DamienMcKenna’s picture

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.

DamienMcKenna’s picture

Begone, unwanted issue tag.

Summit’s picture

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

DamienMcKenna’s picture

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

Summit’s picture

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

subhojit777’s picture

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.

subhojit777’s picture

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.

Summit’s picture

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

subhojit777’s picture

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

Summit’s picture

@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

subhojit777’s picture

@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.

subhojit777’s picture

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

Summit’s picture

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

Summit’s picture

Issue summary:View changes

Clarified the purpose of the issue.

rahulchauhan’s picture

'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

Slurpee’s picture

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...

DamienMcKenna’s picture

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

dkalish’s picture

[Moved over from #1434756]
I previously reported a WSOD when trying to migrate, but that was my problem (standard profile was not set to 1, if anyone's interested). However, I'm still not seeing any metatags in the migrated solution.
Details:
Migrating from D6.33 to D7.31
Followed directions in #1434756 #18 after applying patch and #29.
Nodewords_migrate and metatag-1.0-alpha6 installed and enabled without errors.
No errors from running nodewords_migrate.
When I get to the stage of overriding metatag configurations, I see only 5 entries (GLobal, Global: Front Page, Content, Taxonomy, User) and each only has something about the site name in it. Is this correct?
After uninstalling nodewords and updating metatag to the current recommended version the metatag types are Global:403. GLobal: 404, Global: Front page, Unknown (node), Unknown(taxonomy term), Unknown(user).
There is no metatag block on the page edit pages.

Any help would be appreciated.

dkalish’s picture

The Unknown metatag issue seems to be related to the Metatag module. It appears that nodeword_migrate does its job correctly.

Ralph Musco’s picture

Thanks to everyone who contributed to all the threads on migrating to Metatags from Nodewords and Page Title. I was running into problems because Metatag moved over the page_titles correctly, but when I ran the nodewords_migrate module it was erasing them. This is how I finally got my data moved over in case it helps anyone else...

1) I exported my page_titles table to a php array via phpAdmin

2) I wrote a little php program to insert all the data from page_title into the nodewords table. In my case:
- all my page_title 'types' were 'nodes' which is a '5' for 'type' in nodewords (I found this info in the nodewords_migrate.admin.inc).
- 'id' in nodewords and page_title is the same (the nid)
- I set 'name' in nodewords to 'title'
- The 'content' field was created by using serialize(array('value'=>$titlearr['page_title'])); where $titlearr was the php array I exported in #1 (I got the format from the nodewords_migrate.admin.inc).

3) At this point I had all my page titles in the nodewords database. I installed the alpha 6 release of Metatag.

4) I ran the latest version of nodewords_migrate which brought all my data including the titles into the Metatags table.

5) At this point I installed Metatags 7.x-1.0-rc2 (which was the latest version at the time) and tried to run update.php which choked on update 7013. I checked the Metatag table and found I had a few entries that were missing an entity type and had no data. I recorded the node numbers for these records and deleted them. After this, all updates installed fine.

6) I checked the nodes I deleted the data for in #5 and found that somehow all their metadata was there.

size’s picture

I was just successful with this using instruction from here
#18 https://www.drupal.org/node/1434756#comment-6914602 (as per comment #60 above)

used nodewords migrate module #26 https://www.drupal.org/node/1434756#comment-8150677
with patch/diff file from #30 https://www.drupal.org/node/1434756#comment-8980871
(I had no need to use #29 in the same thread)

d7 version 7.34
metatag 7.x - 1.4
nodewords 6.x-1.12-beta9

this is good compared to over a year ago when I had no success at this, so moved those sites to metatags quick. anyhow just thought I'd let you know this works.

Summit’s picture

Hi,
I also want to migrate, but uses also custom pages nodewords D6 module (https://www.drupal.org/project/nodewords_pagetitle)
Is there any change to also migrate those..? Do I need to set up another issue for this please?
Thanks a lot in advance for your reply!
Greetings, Martijn

DamienMcKenna’s picture

@Summiy: Please open a new issue for that.

Summit’s picture

Hi Made new issue https://www.drupal.org/node/2388205 for https://www.drupal.org/project/nodewords_pagetitle migration.
Thanks! Greetings, Martijn

tonu110’s picture

I have did exactly like #63, everything is fine but 'abstract'(metatag) part of all the content haven't migrated and showing default value. Please help

Summit’s picture

Hi, Made new issue https://www.drupal.org/project/nodewords_pagetitle , but no reaction until now..
@subhojit777 you solved with migrate I read, right?
greetings, Martijn

DamienMcKenna’s picture

DamienMcKenna’s picture

FYI at work we're working on a project that'll have me finishing this off, so look for an update sometime in May.