Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
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.
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:
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
Comment | File | Size | Author |
---|---|---|---|
#1 | 870820.patch | 526 bytes | EclipseGc |
Comments
Comment #1
EclipseGc CreditAttribution: EclipseGc commentedOK, quick little fix for this:
Comment #2
EclipseGc CreditAttribution: EclipseGc commentedComment #3
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted. Thanks!