Installed module. Exported a node: "page" content type. Copied code. Went to "Import" and pasted code. Got these errors when I clicked on "Import".

    * warning: current(): Passed variable is not an array or object in /var/www/html/websites/drupal/test/modules/node_export/export.pages.inc on line 128.
    * warning: call_user_func_array(): First argumented is expected to be a valid callback, '_node_form' was given in /var/www/html/websites/drupal/test/includes/form.inc on line 366.

Using Drupal 6.9.

Any suggstions?

Comments

somebodysysop’s picture

Oh, I forgot to add, here is the code I'm attempting to import:

class stdClass {
  var $nid = NULL;
  var $type = 'page';
  var $language = '';
  var $uid = '1';
  var $status = '1';
  var $created = NULL;
  var $changed = '1236202652';
  var $comment = '0';
  var $promote = '0';
  var $moderate = '0';
  var $sticky = '0';
  var $tnid = '0';
  var $translate = '0';
  var $vid = NULL;
  var $revision_uid = '1';
  var $title = 'Operation_Predator_Press_Kit';
  var $body = 'Protecting America\'s Children Homeland Security<br><br>http://www.workplaceviolence911.com/docs/20050817.pdf';
  var $teaser = '';
  var $log = '';
  var $revision_timestamp = '1236202652';
  var $format = '0';
  var $name = 'somebody';
  var $picture = '';
  var $data = 'a:0:{}';
  var $last_comment_timestamp = '1236202652';
  var $last_comment_name = NULL;
  var $comment_count = '0';
  var $taxonomy = 
  array (
    163 => 
    class stdClass {
      var $tid = '163';
      var $vid = '1';
      var $name = 'Background Screening & Hiring Process';
      var $description = '1186';
      var $weight = '0';
    },
    170 => 
    class stdClass {
      var $tid = '170';
      var $vid = '2';
      var $name = 'Links';
      var $description = 'Links.';
      var $weight = '0';
    },
  );
  var $files = 
  array (
  );
  var $webfm_files = 
  array (
  );
  var $menu = NULL;
  var $path = NULL;
}
danielb’s picture

Did you export a node... or a content type? This is not for content types, that functionality is already there.

somebodysysop’s picture

I went to the page node whose source I listed above. I clicked on "Export" tab on the node. The above is what I got. I then copied and pasted the above into the "Import" box. Clicked on "Import" button. Got the errors I listed at the top of this issue and nothing else.

It looks like the program is saying that the node object I pasted in is not being recognized as a node object, but I haven't a clue as to what to do since I believe I've followed the instructions to the letter.

danielb’s picture

are you using php 4 ? Looks like it gives different output to php 5 and I haven't handled it correctly.

somebodysysop’s picture

Yes, I'm running PHP 4.7. That's it? This module will only work with PHP 5? Any workarounds?

danielb’s picture

I'll have to change the code to accept your node code that you pasted up there

danielb’s picture

I'm thinking of changing the import/export code to use these functions I found

<?php
function encode($var){
    if (is_array($var)) {
        $code = 'array(';
        foreach ($var as $key => $value) {
            $code .= "'$key'=>".encode($value).',';
        }
        $code = chop($code, ','); //remove unnecessary coma
        $code .= ')';
        return $code;
    } else {
        if (is_string($var)) {
            return "'".$var."'";
        } elseif (is_bool($code)) {
            return ($code ? 'TRUE' : 'FALSE');
        } else {
            return 'NULL';
        }
    }
}

function decode($string){
    return eval('return '.$string.';');
}
?>

Will just need to add in handling for objects, ints, and other data types.
Hoepfully this method will be more consistent.

danielb’s picture

Title: Trying to export and then import in 6.x throws errors » Import in PHP4 throws errors

OK i've added it to the DRUPAL 6 version of the module, if this works out I will backport.

somebodysysop’s picture

Thank you. Downloaded 6.x-2.2 and installed. Tried to import code from above:

# warning: Invalid argument supplied for foreach() in /var/www/html/websites/drupal/test/modules/node_export/export.pages.inc on line 310.
# warning: call_user_func_array(): First argumented is expected to be a valid callback, '_node_form' was given in /var/www/html/websites/drupal/test/includes/form.inc on line 366.
danielb’s picture

No you will need to generate new code :(

somebodysysop’s picture

Yes! Whoo-Hoo! Thank you so much!

One final question: Can the 5.x version be made to export in this fashion so that we could do 5.x to 6.x node transfers?

danielb’s picture

Yeah I will do this soon, got some other work I need to do first :/

somebodysysop’s picture

Thank you! Good show.

danielb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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