Download & Extend

Create upgrade path from Embedded Media Field (6.x) to Media module (7.x)

Project:Embedded Media Field
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:gci-code, gci-medium

Issue Summary

Description
For this task you will create an upgrade path from the Drupal 6 version of Embedded Media Field (emfield) to the Drupal 7 version of Media.

The Media module provides a framework for managing files and multimedia assets, regardless of whether they are hosted on your own site or a 3rd party site. It replaces the Drupal core upload field with a unified User Interface where editors and administrators can upload, manage, and reuse files and multimedia assets. For Drupal 7, Embedded Media Field's functionality is being replaced by the Media Module, which takes advantage of Drupal's new PHP stream wrapper support, however there currently is no upgrade path to move from Emfield to Media.

Deliverables
Patch against Media Module that creates an upgrade path for Drupal 6 emfield users.

Resources
Media Module: http://drupal.org/project/media
Emfield Module: http://drupal.org/project/emfield
Media Group: http://groups.drupal.org/media
Media Module FAQ: http://groups.drupal.org/node/19746

Mentors
None yet, possible mentors are JacobSingh and aaron (Aaron Winborn). I'm also happy to assign someone here at Zivtech to mentor.

Comments

#1

Status:active» needs work

#2

To do this, we will need to handle several steps:

1) Discover any fields with emfield (emvideo/emaudio/emimage) field data.
2) Grab the list of providers supported (such as youtube/bliptv/flickr/etc).
3) Map that to supported providers (Media: YouTube, Media: BlipTV, Media: Flickr, etc).
4) Flag any currently unsupported providers.

We can look at the d6 function emfield_audit() to help with steps 1-4: it currently returns an array of providers that are not supported in d6. Can probably be refactored fairly easily for d7.

5) Back up the old field data tables and convert all emfield fields (emvideo/emaudio/emimage) to media fields, probably by simply creating the new fields.
6) Move old data to the new required format, which includes calling each specific provider uri construction, which will return codes like youtube://v/xcf32yy89, brightcove://u/3245yu342/v/7r89w0dc etc. There is currently no straightforward conversion from the old data (which in those cases might store as 'provider' => 'youtube', 'value' => 'xcf32yy89' or 'provider' => 'brightcove', 'value' => '7r89w0dc'. Instead, we need to call it's hook_media_parse() with the $url currently returned by emfield_parse_embed($field, $embed, $module), where $field is the d6 field info, $embed is the $url, and $module is emvideo/emaudio/emimage.

Confusing, but I believe these steps will handle it for supported providers. We would need to ensure we keep the old data in case there are unsupported providers (waiting on the other modules to upgrade to d7), and put the whole thing in a batch. Also delete values as they're processed, so we can safely rerun the batch job if we later add supported modules.

Please let me know if there's anything else that can be done to simplify and streamline the process. I'm particularly interested in anything that could make the upgrade as painless as possible for the end admins.

#3

Also note that this will not handle eminline data. I'm not sure of the best way to handle that, but I suspect it will be easier in some respects (more difficult in others), as media already supports wysiwyg. We might need to create a new format filter module for that, as the inline code is different than in media (and simpler in some respects, as it simply converts a url to the embedded media).

#4

Also, this won't handle thumbnails. But I don't think that will be an issue in *most* cases, as thumbnail handling has already been tackled afaik w/ media. Unfortunately, it will mean that all custom thumbnail data will be lost (during this phase), as there is no such allowance in media. I suppose for the purposes of this task we would simply make a big note on the project page to that effect, so that admins can make their decision based on their specific needs. However, it might be best to *not* delete old data, but to simply mark it done, so that we can go back later to retrieve any other specific data required that's missed this time around.

#5

Status:needs work» reviewed & tested by the community

Aaron, did you want to officially mentor this task?
I'll be sweeping whatever I can into GCI tomorrow morning (Tuesday, 7/7).

#6

Yes, I can mentor this task.

#7

Status:reviewed & tested by the community» fixed
Issue tags:-gci-needs-mentor

And by 7/7, I mean 7/9. Added with myself as a mentor until Aaron's a mentor on GCI.
Aaron, there's one more step to becoming a mentor, you get to fill out a mentor profile before you're listed as possible mentors.

#8

Status:fixed» closed (fixed)

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

#9

Project:Google Code-in» Embedded Media Field
Version:<none>» 6.x-2.x-dev
Status:closed (fixed)» active

moving this issue to emfield. not sure if it ever got picked up at gsoc.

#10

Regarding #4 I think the data migration should be as carefully as the CCK migration is. The old data should not be destroyed after the migration is complete to enable us to go back and fix it/try again until it is "perfect". Personally, for my sites losing the custom thumbnails is not a big thing, as we in most cases use the one provided through the API of Youtube/Vimeo etc.
Subscribing ;)

#11

Subscribing.

#12

subscribe.

#13

I guess this migration should be listed on the modules page. And maybe remove the d7 pledge ;)

(I was researching how to write a emfield provider for D7)

#14

subscribe

#15

Assigned to:Anonymous» Alex UA

I'm assigning this to myself for now-> the actual work will be done by justin.randell in the very near future.

#16

subscribe

#17

Anything that can be done to help? (Didn't want to just say "Subscribe.")

#18

subscribe.

#19

Assigned to:Alex UA» beejeebus

this work is being done in the 7.x-1.x branch, but i can't seem to set the version to that.

commits so far, which just get through the easy bit of hooking up media module as responsible for the D7 fields:

http://drupalcode.org/project/emfield.git/commit/2395e94
http://drupalcode.org/project/emfield.git/commit/74a38cd

#20

Subscribe

#21

Hi Justin
Was unable to find any commits after the two you mention in #19. Could you enlighten us on where we are at the moment and do you have anything in your sandbox we should know about? I'll guess there more then me that are looking on migrating emfield to the media module.

#22

@justin: we need to create a new release for the 7.x-1.x branch before we can change the issue version.

#23

Assigned to:beejeebus» Anonymous

#24

Subscribe

#25

Subscribe

#26

Category:task» feature request

Subscribe

#27

subscribe

#28

Subscribe

#29

subscribe.

#30

Subscribe.

#31

subscribe

#32

+1

#33

subscribe

#34

subscribe. the D6 -> D7 upgrade path has been surprisingly painless thus far... but this would really help cross the finish line!

#35

+1

#36

Subscribe too.

#37

subscribe

#38

#39

+2 (separate customers)

#40

Status:active» needs work

http://drupalcode.org/sandbox/kleinmp/1261456.git/commitdiff/64ec01b

This currently ignores all settings, and has only been tested with media_youtube. But it "works".
I'm considering opening another issue to add URI scheme as a key for hook_media_internet_providers(), since I can't see another way to derive it.

Using the 2.x branch of Media.

#41

I forgot to mention, it needs this bug fix for content_migrate: #1266962: When migrating content, reuse altered instance

#42

awesome work! i've got it set to a file field instead, and it's working well. i agree w/ you re. the hook_media_internet_providers() idea; i'll create an issue & patch for that if you haven't already.

#43

Thanx for the project
with latest build from sandbox i had foll issue and it looks that after a night of tries with db i have mostly overcame it by pushing F5 each time migration failed.

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=259&op=do StatusText: Service unavailable (with message) ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'youtube://v/1C9nFS51z6o' for key 'uri': INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize, status, timestamp, type) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => 1C9nFS51z6o [:db_insert_placeholder_2] => youtube://v/1C9nFS51z6o [:db_insert_placeholder_3] => video/youtube [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1321419702 [:db_insert_placeholder_7] => video ) in drupal_write_record() (line 6884 of /var/www/mysiite.com/includes/common.inc).

#45

Version:6.x-2.x-dev» 7.x-1.x-dev
Status:needs work» fixed

http://drupalcode.org/project/emfield.git/commitdiff/e86f55d?hp=2395e941...

this upgrades from emfield d6 to file d7. requires content migrate (part of cck) and media.

#46

@aaron Thanks for the effort but please please add a banner to the project page containing first lines ie

This project is superseded by the media module.

To migrate your http://drupal.org/project/emfield data your need to download the Drupal 7 version of this module together with content migrate which is part of http://drupal.org/project/cck) and http://drupal.org/project/media

Please publish the D7 version so we can all test this too :-)

#47

#48

Status:fixed» closed (fixed)

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

#49

After reading this thread, I still have little clarity about how this upgrade path is supposed to work. I attempted to migrate a large number of youtube embed fields and the fields were created -- that was great! However, they did not get populated with anything -- not so great. I used the below code, hacked from this stackoverflow post.

<?php
$sql
= "SELECT nid, field_video_embed from content_type_video_page";
$results = db_query($sql);
foreach(
$results as $record) {
   
from_youtube($record->nid, $record->field_video_embed);
}

// include the media youtube handler.inc file to use the embed code parsing

function from_youtube($nid, $code) {
   
$path = drupal_get_path('module','media_youtube').'/includes/MediaInternetYouTubeHandler.inc';     
    require_once(
$path);
   
$occurs = strpos($code, 'youtube');
   
$node = node_load($nid);
   
$video_title = (strlen($node->title) > 255) ? substr($node->title,0,250).'...' : $node->title;
    if(
$occurs !== false) {
        try {
       
$code = MediaInternetYouTubeHandler::parse($code); 
       
$youtube = file_uri_to_object($code, $use_existing = TRUE);
       
$youtube->display = 1;
       
$youtube->filename = $video_title;
       
$youtube->uid = 62;
       
$youtube = file_save($youtube);
       
$node->field_video[LANGUAGE_NONE][0] = (array) $youtube;
       
node_save($node);
        print
"Updating | $node->nid \n";
        } catch (
Exception $e) {
            echo
'Caught exception: '$e->getMessage(), "\n";
        }
    }
}
?>

Obviously, you'd need to change the field and table names in the sql query to fit your site. This should work for most youtube videos, assuming your node has a media field configured to handle embedded media from youtube using the media_youtube module.

#50

hello sorry if this is long dead which might be a good thing for me. Ive just done a migration 6>7 and it went smotther than i had hoped. I have all the old youtube vids converted and are now emfields. Just need to find out how to convert them to a Media field now?

Thank (i know that no one will answer :(

nobody click here