Just curious, will this work with the Media and File Entity module combos?

Comments

bailey86’s picture

I'm not familiar with those modules.

Basically, on export, the whole node object gets serialised, base64 encoded and put into the dataset file. On import the lines are read in from the dataset file, decoded and the node object is recreated from the serialised data. So if the modules are adding data to the node object then the data should go out and back in again.

The data which needs to be dealt with specially is attached files. For the D7 module the export will look at the object and look for to see if it references attached files. If it does then those files are retrieved from the file system via the API - then are then base64 type encoded (into text strings) and then attached to the node object.

On import the object is examined - if any attached files are found then the data part is extracted, re-encoded and saved to the file system. The ID number is then used to link it to the object.

Hope that helps explain what happens - and maybe that helps.

As always - if you're not sure I'd recommend creating a vanilla D7 site and try the export/import with a single node.

If you need a script to help create Drupal sites quickly you could have a look at the scripts which are at:

https://github.com/SSVC/pullpush

Cheers,

Kevin B

gmclelland’s picture

Thank you for the response.

Here are the modules I was talking about.

http://drupal.org/project/media and http://drupal.org/project/file_entity

I believe file_entity is headed for Drupal core in D8.

I really like the idea of this module, but I was wondering how it can handle other entities?

For example:
Entity Registrations - http://drupal.org/project/registration
Entity Forms - http://drupal.org/project/entityform
File Entities - http://drupal.org/project/file_entity - This one is my main concern
Organic Groups - http://drupal.org/project/og

A lot of their configuration can be exported to code, but the entities themselves are considered content that needs to be migrated for the site to be considered complete. That's the part I'm unsure of how to handle.

Well, even if it can solve those problems it can still probably solve the problem of taxonomy terms and users that need to migrated.

Thanks again

bailey86’s picture

The Media module looks compatible. DEI handles files in the native Drupal way. The only wrinkle is that on import the files attached to nodes are saved first and then the ID they are given is used in the node. This is because when the file is saved it may be given a different ID number from the site which exported it.

The file_entity module may be OK - as long as the data it adds is added to the node object then this should be exported and imported.

As usual - test with a small vanilla site and see how it goes.

Cheers,

Kevin B

bailey86’s picture

Status: Active » Postponed (maintainer needs more info)

Are there any results from testing to report back?

gmclelland’s picture

No sorry, I haven't tested it. I got worried when you said that the file ids can change. What happens when those files are referenced somewhere else throughout the site? Wouldn't the references be pointing to the wrong file?

bailey86’s picture

Existing files should be OK.

Say you export a node and it has an attached file with an ID of 123. The dataset file will contain the node object with the file data added as an extra field on the object.

OK - so now we import the node (object). So we look at the object and see that it has a file attached. OK, we recreate the file and add it to the receiving Drupal site. BUT! say there is already a file in the receiving site with the ID of 123 - we would have problems. So what the code does is to add the file - and then retrieve the ID number which was issued to the file - say 127. Then, when we save the node object we set the attached file ID to 127 to match the file which was imported.

So, existing files are not touched - imported nodes have there attached files imported. The only difference is that the reference ID from the node to the ID may be different.

It's difficult to think of how this would all be done differently. We could be more brutal and delete files on the receiving system which have the ID of the exported attached file - but that might be for a different content type which is not being exported/imported.

Any thoughts, ideas etc would be gratefully received.

gmclelland’s picture

The scenario you are describing sounds like a node with a file/image field use the file entity and media modules, but media module also allows images and files to be inserted inline into body field using the WYSIWYG API + TinyMCE or CkEditor.

How would it work for nodes that have inline media?

bailey86’s picture

Hmmmm... Very tricky.

It would maybe resolved by an option on the module. Something like:

'Remove any existing files and import the new files with their existing ID's (Needed for the media module) - Tick/Untick

Say the site has other content types which have files attached - would you be happy to remove all those files or possibly even all the nodes?

bailey86’s picture

Status: Postponed (maintainer needs more info) » Postponed

This could be an option as mentioned. A fairly brutal option as mentioned:

'Remove all existing files and import new files with their existing ID's (Needed for the media module for example) - Tick/Untick'

This would mean that all new files would be imported and would be given the same fid as when they were exported - this might be needed for certain scenarios as mentioned.

I'm going to mark this as postponed until a patch is supplied or someone wants to supply sponsorship for me to add this.

bailey86’s picture

Status: Postponed » Closed (works as designed)

Aha! I've just been looking at the Media module.

In-line image links would be fine as the links are the the file's name.

I'd appreciate someone giving some feedback on this - but for now I'm going to mark this as closed - works as designed. Please feel free to re-open this issue if needed.