I've clone an importer with several tamper items attached, but they are not cloned as well, so I have to manually add them one by one again. This was unexpected.

Comments

twistor’s picture

Assigned: Unassigned » twistor
Category: bug » feature

I can see how this would be desired, but not sure if it's expected. Maybe we can add a checkbox to the clone form asking if you'd like to clone the plugins?

Other opinions?

franz’s picture

Title: Cloning Feeds Importer doesn't work with Tamper » Cloning/Exporting Feeds Importer doesn't work with Tamper

Yes, it could be optional, as long as it's easy. I just think it's expected in the case you want to build a very similar feeds importer with similar settings.

I haven't tried, but I think exporting also needs this (even if optional), specially for deploying.

lodey’s picture

I've just had this issue. To get around it for now I am using Features - but this is still a real big pain to be honest.

I packaged up my feed importer and its associated tamper plugins into a single feature. I then copied the feature module and all files to a feature naming convention for the cloned version. You then need to go through all the files and changed all the functions and text to cover your new feed..... This is a real pain - but still quicker than rebuilding all the tamper plugins if you have quite a few.

It would be great if this functionality could be included into the tamper module - but in the meantime this work around is fine for me.

franz’s picture

Even when using features, you have to manually select everything. Then you add a couple more tampers, you can't forget that when recreating the feature you have to go back and add them all again. They should work the same way as a Content Type & Fields: Fields get added automatically to the feature.

geefin’s picture

While awaiting for patch/module/etc... I cloned the importer, then into the database here's the sql :-

INSERT INTO feeds_tamper
          ( id, importer, source, plugin_id, settings, weight, description)
     SELECT REPLACE(id, '***IMPORTER MACHINE NAME TO CLONE***', '***NEW IMPORTER MACHINE NAME***'), '***NEW IMPORTER MACHINE NAME***', source, plugin_id, settings, weight, description
      FROM feeds_tamper WHERE importer = '***IMPORTER MACHINE NAME TO CLONE***';
aouko’s picture

For everyone's information, there's a new module that provides cloning for Feeds Tamper: http://drupal.org/sandbox/mamanerd/1906440

mamanerd’s picture

Hey everyone, here's a patch that will allow you to clone tamper plugins when cloning a feeds importer. I originally made it into a separate module, but realized that was not really necessary. Let me know if you have any issues!

mamanerd’s picture

Status: Active » Needs review
StatusFileSize
new2.56 KB

Setting this to "needs review" so that the patch gets reviewed.

Status: Needs review » Needs work

The last submitted patch, feeds_tamper-clone_tamper_plugins-1346936-8.patch, failed testing.

mamanerd’s picture

Status: Needs work » Needs review
StatusFileSize
new2.56 KB

Attempting to submit patch again..

Status: Needs review » Needs work

The last submitted patch, feeds_tamper-clone_tamper_plugins-1346936-10.patch, failed testing.

mamanerd’s picture

Can someone help me figure out why my patch keeps failing? It applies cleanly when I try to apply it to the 7.x-1.x branch locally. Any ideas?

perke’s picture

Thanks for the info, module in #6 works flawlessly!

phew, lots of time saved

drclaw’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
Status: Needs work » Needs review

@mamanerd You have to change the version on the issue so the testbot knows which version to apply the patch to.

drclaw’s picture

drclaw’s picture

Patch has error:

Fatal error: Call to undefined function feeds_tamper_clone_clone_tamper_plugins() in /home/chris/www/taymor/includes/form.inc on line 1464

RE-roll attached.

muschpusch’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Ok #16 works as designed and is pretty useful! Code looks good too

geek-merlin’s picture

Priority: Normal » Major

I can also confirm #16 works as announced. Code looks simple and clean.

I consider this feature is so basic and expected that i dare to ries priority. Feel fre to rearrange that.

twistor’s picture

Assigned: twistor » Unassigned
Status: Reviewed & tested by the community » Needs work

This is awesome!

  1. +++ b/feeds_tamper_ui/feeds_tamper_ui.module
    @@ -139,3 +139,64 @@ function feeds_tamper_ui_source_name(stdClass $instance) {
    +    // Let's get the #from_importer ID.
    +    $from_importer_id = isset($form['#from_importer']->fetcher->id) ? $form['#from_importer']->fetcher->id : '';
    

    This can just use $form['#from_importer']->id.

  2. +++ b/feeds_tamper_ui/feeds_tamper_ui.module
    @@ -139,3 +139,64 @@ function feeds_tamper_ui_source_name(stdClass $instance) {
    +    if ($from_importer_id) {
    +      $tamper_plugins = feeds_tamper_load_by_importer($from_importer_id, FALSE);
    +    }
    

    So then $tamper_plugins can be undefined?

  3. +++ b/feeds_tamper_ui/feeds_tamper_ui.module
    @@ -139,3 +139,64 @@ function feeds_tamper_ui_source_name(stdClass $instance) {
    +    foreach ($tamper_plugins as $tamper_plugin) {
    +      foreach ($tamper_plugin as $old_instance) {
    

    Need different names for these variables.

  4. +++ b/feeds_tamper_ui/feeds_tamper_ui.module
    @@ -139,3 +139,64 @@ function feeds_tamper_ui_source_name(stdClass $instance) {
    +        $new_instance = feeds_tamper_new_instance();
    +        $new_instance = $old_instance;
    

    Why call feeds_tamper_new_instance() then overwrite it with the old instance. We should just clone $old_instance.

  5. +++ b/feeds_tamper_ui/feeds_tamper_ui.module
    @@ -139,3 +139,64 @@ function feeds_tamper_ui_source_name(stdClass $instance) {
    +        $new_instance->id = str_replace($from_importer_id, $form_state['values']['id'], $new_instance->id);
    

    stre_replace() isn't safe to use here. Should use explode('-', $id, 2).

  6. +++ b/feeds_tamper_ui/feeds_tamper_ui.module
    @@ -139,3 +139,64 @@ function feeds_tamper_ui_source_name(stdClass $instance) {
    +        $new_instance->export_type = NULL;
    

    Isn't there a constant for this?

  7. +++ b/feeds_tamper_ui/feeds_tamper_ui.module
    @@ -139,3 +139,64 @@ function feeds_tamper_ui_source_name(stdClass $instance) {
    +        unset($new_instance->disabled);
    

    Should disabled plugins stay disabled?

maxplus’s picture

Hi,

#16 works for me with the current stable version 7.x-1.0.

Thanks,
great feature that makes life more easy!

thomas.krooshof.bc’s picture

#16 works with latest dev version 7.x-1.x-dev. Thanks!

  • twistor committed 133fba2 on 7.x-1.x authored by mamanerd
    Issue #1346936 by mamanerd, drclaw, franz, twistor, axel.rutz, geefin,...
twistor’s picture

Status: Needs work » Fixed
twistor’s picture

Status: Fixed » Closed (fixed)

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