The ctools_export_crud_import() function passes $object and $indent to the import callback specified in a table's schema, however those variables are not defined before being passed.

<?php
function ctools_export_crud_import($table, $code) {
 
$schema = ctools_export_get_schema($table);
 
$export = $schema['export'];

  if (!empty(
$export['import callback']) && function_exists($export['import callback'])) {
    return
$export['import callback']($object, $indent);
  }
  else {
   
ob_start();
    eval(
$code);
   
ob_end_clean();

    if (empty(${
$export['identifier']})) {
     
$errors = ob_get_contents();
      if (empty(
$errors)) {
       
$errors = t('No item found.');
      }
      return
$errors;
    }

   
$item = ${$export['identifier']};

   
// Set these defaults just the same way that ctools_export_new_object sets
    // them.
   
$item->export_type = NULL;
   
$item->type = t('Local');

    return
$item;
  }
}
?>

This is a pretty easy fix, but I'm unsure of the $indent. The crud_export function is passed $indent, and I'm frankly wondering if the import callback has any real use for it since it's just going to eval($code) and it's not actually formatting any sort of output.

Thinking the fix could be as simple as:

<?php
function ctools_export_crud_import($table, $code) {
 
$schema = ctools_export_get_schema($table);
 
$export = $schema['export'];

  if (!empty(
$export['import callback']) && function_exists($export['import callback'])) {
    return
$export['import callback']($code); // FIX
 
}
  else {
   
ob_start();
    eval(
$code);
   
ob_end_clean();

    if (empty(${
$export['identifier']})) {
     
$errors = ob_get_contents();
      if (empty(
$errors)) {
       
$errors = t('No item found.');
      }
      return
$errors;
    }

   
$item = ${$export['identifier']};

   
// Set these defaults just the same way that ctools_export_new_object sets
    // them.
   
$item->export_type = NULL;
   
$item->type = t('Local');

    return
$item;
  }
}
?>

Eclipse

Files: 
CommentFileSizeAuthor
#1 870820.patch526 bytesEclipseGc

Comments

EclipseGc’s picture

StatusFileSize
new526 bytes

OK, quick little fix for this:

EclipseGc’s picture

Status:Active» Needs review
merlinofchaos’s picture

Status:Needs review» Fixed

Committed. Thanks!

Status:Fixed» Closed (fixed)

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