Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rickvug’s picture

Title: Upgrading from "Meta tags quick 7.x-2.0" to "Metatag" » Upgrade path from Meta tags quick
Version: 7.x-1.0-alpha1 »
Category: support » feature
mgifford’s picture

Agreed that this would be useful!

wellsys_world’s picture

Subscribe please

rickvug’s picture

@Wellsy Note that there is now a follow button in the top right. No need to comment to subscribe!

wellsys_world’s picture

Thanks @rickvug. Is that new?

Edit: Just seen the homepage - yes it is new. Nice

rickvug’s picture

@Wellsy Yes, as of yesterday I believe. See http://drupal.org/node/1306444 for the announcement.

Murz’s picture

Version: » 7.x-1.0-alpha6

Here is code snippet for copy node metatags from metatags_quick to metatag module:

  $result=db_query("SELECT node.nid, field_data_meta_description.meta_description_metatags_quick, field_data_meta_keywords.meta_keywords_metatags_quick FROM {node} 
  LEFT JOIN {field_data_meta_description} ON (field_data_meta_description.entity_type='node' AND field_data_meta_description.entity_id=node.nid)
  LEFT JOIN {field_data_meta_keywords} ON (field_data_meta_keywords.entity_type='node' AND field_data_meta_keywords.entity_id=node.nid)
  ");
  foreach($result as $row) {
    if(!empty($row->meta_description_metatags_quick)) $metatags[$row->nid]['description']['value']=$row->meta_description_metatags_quick;
    if(!empty($row->meta_keywords_metatags_quick)) $metatags[$row->nid]['keywords']['value']=$row->meta_keywords_metatags_quick;
  }
  
  foreach($metatags as $id=>$item) {
    db_merge('metatag')
      ->key(array(
        'entity_type' => 'node',
        'entity_id' => $id,
      ))
      ->fields(array(
        'data' => serialize($item),
      ))
      ->execute();
  }
DamienMcKenna’s picture

Title: Upgrade path from Meta tags quick » Upgrade path: Meta tags quick
Issue tags: +Upgrade path
DamienMcKenna’s picture

Component: Documentation » Code
Category: feature » task
HyperGlide’s picture

Cross linking to #1658970: Upgrade path: Page_Title. For Page Title module migration information.

iamEAP’s picture

Status: Active » Needs review
FileSize
3.08 KB

Here's a drush command metatag-import-mtq that is essentially a more complete version of the code snippet provided in #7. In addition to the fields left out there, it handles language as expected and clears the metatag cache for all nodes.

Don't know what the maintainers are thinking strategically for these "upgrade paths" (separate module, providing a GUI, etc.), but this drush command could easily be moved somewhere else and just invoked from drush in a different way.

iamEAP’s picture

Adding a check for the existence of the Meta Tags quick field tables. Also adding some feedback about how much data is being imported.

Also realized that this doesn't take into account Meta Tags Quick path-based meta tags, which I don't use.

HyperGlide’s picture

Thanks for the updates and patches.

We do make use of path passed meta tags on our site.

iamEAP’s picture

Here's a patch that also takes care of Meta Tags Quick paths by generating a series of contexts. It checks that Meta Tags: Context is enabled before attempting.

Also added support for the Meta Tags Quick canonical field that the previous patches missed.

Attempted to bring over "revisit after" data, but I don't think this module supports it, currently.

iamEAP’s picture

Noticed there was a problem migrating robots fields; Meta Tags expects them in the form array('noindex' => 'noindex'), while the previous patch was feeding it array('noindex').

This patch takes care of that. Otherwise, the same.

HyperGlide’s picture

HyperGlide’s picture

Status: Needs review » Needs work

I tested this on the latest beta of Meta tag.

Path based meta tags worked.

Node meta data did not update.

Drush reported that the values where created. When inspect the Node/xx/edit and DB the values are not present.

Suggestions?

DamienMcKenna’s picture

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

Lets retest it.

DamienMcKenna’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

HyperGlide’s picture

Will keep an eye on this when the testing is complete will run again. Think i need a new test site or re run on the same site I used earlier?

HyperGlide’s picture

Is the same patch, why we expect different results?

HyperGlide’s picture

HyperGlide’s picture

Status: Needs review » Reviewed & tested by the community

Retested on a new clone of our site and the (2) meta types we where using imported properly.

They include Meta Keyword and Meta Description.

HyperGlide’s picture

Updated -- after completing my testing for this issue using the Beta7 version.

I looked to test #1658970: Upgrade path: Page_Title which did include updating to the dev version.
Running updated.php etc.

The values that had once been there where gone.

I will test again and also before moving onto the page title. suggest deleting the old meta_tag_quick fields, removing the old module and installing the db tables.

DamienMcKenna’s picture

Category: task » feature
Status: Reviewed & tested by the community » Needs work

Needs work:

  • Metatag now needs supports the 'REVISIT-AFTER' tag.
  • The page title tag needs to be supported.
  • Does the Metatag module itself need to be listed as a dependency for the task?
  • It must support any entity rather that just nodes.
HyperGlide’s picture

@DamienMcKenna

This issue has been focused on just the https://drupal.org/project/metatags_quick.

Is your post #26 meant to expand this issue?

Metatag now needs supports the 'REVISIT-AFTER' tag.
The page title tag needs to be supported.

metatags_quick does not support these tags.

Does the Metatag module itself need to be listed as a dependency for the task?
It must support any entity rather that just nodes.

I would agree with both.

Is best to keep this a drush command or incorporate into the module as done in #1658970: Upgrade path: Page_Title?

DamienMcKenna’s picture

@HyperGlide: I'm not saying to expand beyond what Metatags_Quick can handle, I'm saying to expand it to cover all of the functionality that Metatags_Quick already can handle. The module uses entity and field hooks, therefore it is not strictly tied to nodes, but this upgrade script can only handle nodes.

Further:

  • The most recent commit, from May, adds support for the page title via the "Set page title" field formatter.
  • The REVISIT-AFTER meta tag can be created by Metatags_Quick, is supported by Metatag, and there's a commented-out line in the script for it, so it should be supported with this upgrade script.

I think this is a good first pass, but it really would be best to rewrite it to actually query the field API configuration rather than only work with a few hardcoded field names.

Basically it may be best to start from the list of meta tags supported by Metatag and see if there's an easy way of migrating any fields matching those tags. It'll be more effort, but IMHO ultimately will provide a better ex

HyperGlide’s picture

@DamienMcKenna thanks for the detailed reply.

victoriachan’s picture

Issue summary: View changes

Sadly this doesn't work now that Metatag supports revision (since metatag 7.x-1.0-beta8). The revision_id column on the metatag table for the imported rows are all set to '0' (the default) as the import script didn't supply this data.

I'll see if I can quickly add this.

Thanks,
Victoria

victoriachan’s picture

I've updated the patch from #15 to include the vid / revision_id data.

Thanks,
Victoria

DamienMcKenna’s picture

Component: Code » Integration with other module
FileSize
8.73 KB

Also for consideration, an update script to migrate the title, description and keywords fields that uses the Fields API to identify which fields to migrate.

DamienMcKenna’s picture

While my update script works for a limited use case, the real goal will be available both a drush script and through the website admin.

DamienMcKenna’s picture

Component: Integration with other module » Importing/migrating data
DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 35: metatag-n1282806-35.patch, failed testing.

osopolar’s picture

Patch #35 won't work as metatag_update_7037() is already in use. Anyway it cant work with an metatag_update_N hook, as it does not update metatag module and I guess it won't work on a fresh installation.

I thought of it as an update for metatags_quick module and changed the function name to metatags_quick_update_7400(). I guess there won't be a version 7.x-4.x of Meta tags quick. This worked for me for a small site. A more solid solution would be create a new module for this purpose with the functionality in hook_install. This module can also take care of the deletion of the metatags quick fields, see also #1341252: Document how to uninstall Meta tags quick.

Beside the renaming of the update hook I had some minor modifications. I added a diff for the old patch from #35 to the new one. Its a normal diff (so a bit harder to read), as interdiff would have marked everything as changed:

  • More explanation in the function description to print warning on drush updb
  • Fallback to entity language if no field language is set
  • Modify delete query to use $quick['language'] instead of $language (see 2.)
  • Watchdog messages.
klokie’s picture

Wouldn't it make more sense to include this functionality with the "metatag_importer" submodule?

Also I needed to change
metatag_metatags_save($entity_type, $entity_id, $revision_id, $data, $langcode);
to
metatag_metatags_save($entity_type, $entity_id, $revision_id, $data, $bundle);
to match the function signature for metatag_metatags_save(); otherwise no meta tags were saved on my multilingual site.

DamienMcKenna’s picture

Status: Needs review » Needs work

@klokie: Excellent point! Yeah, this does need to be moved to scripts for Metatag Installer.

malcomio’s picture

Status: Needs work » Needs review
FileSize
6.62 KB

Here's a patch based on #37, taking into account the feedback above.

I haven't written an admin form for it, but it seems to be working OK from the drush command

dandaman’s picture

Tried the latest patch and it did migrate my data. However, it really gave me no indication to if there was actually any data moved. Maybe just a total number of items imported or something could be added? (In the Page Title import, it does include the number of records it would migrate before confirmation--something like that or, when importing, a bit of output that says what or how much was imported.) Just a thought.

dmenefee’s picture

Quick question: why do patches -32 and later remove the capability of importing path-based metatags quick data? I need to convert MTQ path-based settings to contexts.

DamienMcKenna’s picture

@dmenefee: Maybe because Metatag on D8 doesn't have equivalent functionality yet?

DamienMcKenna’s picture

Skip that, forgot this for D7 not D8.

labboy0276’s picture

I just used this on 7.x-1.22 and it worked great. We inherited a legacy d7 site that had metatag quick on it. Installed metatag, configured metatag, ran drush mtcmq = q'plah.

DamienMcKenna’s picture

Thanks for all the reviews. Lets see if the patch still applies.

Status: Needs review » Needs work

The last submitted patch, 40: upgrade_path_meta_tags-1282806-40.patch, failed testing. View results

DamienMcKenna’s picture

Anyone have time to do a quick reroll?

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

Minor tweaks.

DamienMcKenna’s picture

Further improvements, and now it outputs some status messages as it's working.

  • DamienMcKenna committed fdf5eeb on 7.x-1.x
    Issue #1282806 by DamienMcKenna, iamEAP, osopolar, victoriachan,...
DamienMcKenna’s picture

Committed. Thank you all for your help, I'm glad to finally have this committed.

Also, to @dmenefee - apologies for the snarkiness of my reply in #43, it was unnecessary.

DamienMcKenna’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.