From 785eedcc8397ff4d432570fc0d4e95429dcac64a Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Fri, 4 Apr 2014 13:42:22 +0000 Subject: [PATCH] Make the "undo_function" bit optional. The "undo_function" part of callbacks was required, even though it might not be required for functionality... Make it optional, so we don't end up making/using no-op functions to avoid doing anything. --- includes/ingest.form.inc | 12 +++++++----- islandora.api.php | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 8fd1c6ea..f7979063 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -467,12 +467,14 @@ function islandora_ingest_form_undo_consecutive_callback_steps(array $form, arra * The step which the undo callback is being called on. */ function islandora_ingest_form_undo_callback_step(array $form, array &$form_state, array $step) { - $args = array(&$form_state); - $args = isset($step['undo_function']['args']) ? array_merge($args, $step['undo_function']['args']) : $args; - if (isset($step['undo_function']['file'])) { - require_once drupal_get_path('module', $step['module']) . "/" . $step['undo_function']['file']; + if (isset($step['undo_function'])) { + $args = array(&$form_state); + $args = isset($step['undo_function']['args']) ? array_merge($args, $step['undo_function']['args']) : $args; + if (isset($step['undo_function']['file'])) { + require_once drupal_get_path('module', $step['module']) . "/" . $step['undo_function']['file']; + } + call_user_func_array($step['undo_function']['function'], $args); } - call_user_func_array($step['undo_function']['function'], $args); } /** diff --git a/islandora.api.php b/islandora.api.php index e8b45ba7..d32b7fdf 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -423,13 +423,13 @@ function hook_islandora_undeletable_datastreams(array $models) { * - form_id: The form building function to call to get the form structure * for this step. * - args: An array of arguments to pass to the form building function. - * Required "callback" type specific parameters: - * - do_function: An associate array including: + * "Callback" type specific parameters: + * - do_function: A required associative array including: * - 'function': The callback function to be called. * - 'args': An array of arguments to pass to the callback function. * - 'file': A file to include (relative to the module's path, including * the file's extension). - * - undo_function: An associate array including: + * - undo_function: An optional associative array including: * - 'function': The callback function to be called to reverse the * executed action in the ingest steps. * - 'args': An array of arguments to pass to the callback function.