From b482b405303d1e2a97f1d3196ee53eb5712a88fa Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Mon, 5 Aug 2013 16:55:45 +0000 Subject: [PATCH 1/6] Initial commit for feedback. --- islandora.module | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/islandora.module b/islandora.module index 8a8ee6be..b8109a21 100644 --- a/islandora.module +++ b/islandora.module @@ -52,6 +52,7 @@ define('ISLANDORA_DATASTREAM_INGESTED_HOOK', 'islandora_datastream_ingested'); define('ISLANDORA_DATASTREAM_MODIFIED_HOOK', 'islandora_datastream_modified'); define('ISLANDORA_DATASTREAM_PURGED_HOOK', 'islandora_datastream_purged'); define('ISLANDORA_INGEST_STEP_HOOK', 'islandora_ingest_steps'); +define('ISLANDORA_DERVIATIVE_CREATION_HOOK', 'islandora_derivative'); // Autocomplete paths. define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models'); @@ -1415,3 +1416,36 @@ function islandora_islandora_basic_collection_get_query_filters() { )); } } + +/** + * Implements hook_islandora_datastream_ingested(). + */ +function islandora_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) { + $logging_results = islandora_do_derivatives($object); + dd($logging_results, 'logging'); + foreach ($logging_results as $result) { + + } +} + +function islandora_do_derivatives(AbstractObject $object, $force = FALSE, $all = TRUE) { + $hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array()); + uasort($hooks, 'drupal_sort_weight'); + $results = array(); + dd($hooks, 'hooks'); + foreach ($hooks as $hook) { + if (!$all && !isset($hook['source_dsid'])) { + continue; + } + if (isset($hook['file'])) { + require_once($hook['file']); + } + foreach ($hook['function'] as $function) { + $logging = call_user_func($function, $object, $force); + if (!empty($logging)) { + $results[] = $logging; + } + } + } + return $results; +} \ No newline at end of file From 5bafbd8151986410929a33e7fe2607a0c8a45694 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 7 Aug 2013 13:40:14 +0000 Subject: [PATCH 2/6] Updated with tests. --- islandora.info | 1 + islandora.module | 66 +++++++-- tests/derivatives.test | 185 ++++++++++++++++++++++++ tests/islandora_derivatives_test.info | 7 + tests/islandora_derivatives_test.module | 114 +++++++++++++++ 5 files changed, 362 insertions(+), 11 deletions(-) create mode 100644 tests/derivatives.test create mode 100644 tests/islandora_derivatives_test.info create mode 100644 tests/islandora_derivatives_test.module diff --git a/islandora.info b/islandora.info index fea3ead2..4b48bc29 100644 --- a/islandora.info +++ b/islandora.info @@ -18,4 +18,5 @@ files[] = tests/ingest.test files[] = tests/hooked_access.test files[] = tests/islandora_manage_permissions.test files[] = tests/datastream_versions.test +files[] = tests/derivatives.test php = 5.3 diff --git a/islandora.module b/islandora.module index b8109a21..989dd36e 100644 --- a/islandora.module +++ b/islandora.module @@ -1421,31 +1421,75 @@ function islandora_islandora_basic_collection_get_query_filters() { * Implements hook_islandora_datastream_ingested(). */ function islandora_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) { - $logging_results = islandora_do_derivatives($object); - dd($logging_results, 'logging'); - foreach ($logging_results as $result) { + $logging_results = islandora_do_derivatives($object, array( + 'source_dsid' => $datastream->id, + )); + islandora_derivative_logging($logging_results); +} - } +/** + * Implements hook_islandora_datastream_modified(). + */ +function islandora_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) { + $logging_results = islandora_do_derivatives($object, array( + 'source_dsid' => $datastream->id, + 'force' => TRUE, + )); + islandora_derivative_logging($logging_results); } -function islandora_do_derivatives(AbstractObject $object, $force = FALSE, $all = TRUE) { +function islandora_do_derivatives(AbstractObject $object, array $options = array()) { + $options += array( + 'force' => FALSE, + 'source_dsid' => NULL, + 'destination_dsid' => NULL, + ); $hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array()); uasort($hooks, 'drupal_sort_weight'); $results = array(); - dd($hooks, 'hooks'); + + if ($options['source_dsid'] !== NULL) { + $hooks = array_filter($hooks, function($filter_hook) use($options) { + return !isset($filter_hook['source_dsid']) || + (isset($filter_hook['source_dsid']) && $filter_hook['source_dsid'] == $options['source_dsid']); + }); + } + if ($options['destination_dsid'] !== NULL) { + $hooks = array_filter($hooks, function($filter_hook) use($options) { + return !isset($filter_hook['destination_dsid']) || + (isset($filter_hook['destination_dsid']) && $filter_hook['destination_dsid'] == $options['destination_dsid']); + }); + } + dd($hooks, 'hooooooks'); foreach ($hooks as $hook) { - if (!$all && !isset($hook['source_dsid'])) { - continue; - } if (isset($hook['file'])) { - require_once($hook['file']); + require_once $hook['file']; } foreach ($hook['function'] as $function) { - $logging = call_user_func($function, $object, $force); + $logging = call_user_func($function, $object, $options['force']); if (!empty($logging)) { $results[] = $logging; } } } return $results; +} + +function islandora_derivative_logging(array $logging_results) { + foreach ($logging_results as $result) { + foreach ($result['messages'] as $message) { + if ($message['type'] >= WATCHDOG_WARNING) { + if ($message['type'] == WATCHDOG_WARNING) { + $status = 'warning'; + } + else { + $status = 'status'; + } + drupal_set_message(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array()), $status); + } + else { + watchdog('islandora', $message['message'], isset($message['message_sub']) ? $message['message_sub'] : array(), $message['type']); + } + } + } } \ No newline at end of file diff --git a/tests/derivatives.test b/tests/derivatives.test new file mode 100644 index 00000000..a98753f7 --- /dev/null +++ b/tests/derivatives.test @@ -0,0 +1,185 @@ + 'Islandora Derivative Generation', + 'description' => 'Ensure that the derivative generation hooks return appropriate results.', + 'group' => 'Islandora', + ); + } + + /** + * Creates an admin user and a connection to a fedora repository. + * + * @see IslandoraWebTestCase::setUp() + */ + public function setUp() { + parent::setUp( + array( + 'islandora_derivatives_test', + ) + ); + $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); + $this->connection = new RepositoryConnection($url, $this->admin->name, $this->admin->pass); + $this->connection->reuseConnection = TRUE; + $this->api = new FedoraApi($this->connection); + $this->cache = new SimpleCache(); + $this->repository = new FedoraRepository($this->api, $this->cache); + $this->pid = $this->randomName() . ":" . $this->randomName(); + } + + /** + * Free any objects/resources created for this test. + * + * @see IslandoraWebTestCase::tearDown() + */ + public function tearDown() { + $tuque = islandora_get_tuque_connection(); + parent::tearDown(); + } + + public function testDerivativeOnIngest() { + global $ingest_method; + $ingest_method = 'modifyDatastream'; + $tuque = islandora_get_tuque_connection(); + $object = $tuque->repository->constructObject($this->pid); + $object->models = array( + 'some:cmodel', + ); + $dsid = 'OBJ'; + $ds = $object->constructDatastream($dsid); + $ds->label = 'Test'; + $ds->content = 'test'; + $object->ingestDatastream($ds); + $tuque->repository->ingestObject($object); + $this->assertDatastreams($object, array( + 'RELS-EXT', + 'DC', + 'OBJ', + 'DERIV', + )); + $this->assertEqual('ingestDatastream', $ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('test some string', $object['DERIV']->content, 'The expected content of the DERIV datastream is "test some string", got "' . $object['DERIV']->content . '".'); + } + + public function testDerivativeOnForceExistingDatastream() { + global $ingest_method; + $ingest_method = 'ingestDatastream'; + $object = $this->constructBaseObject(); + $this->constructDERIVDatastream($object); + $islandora_object = islandora_object_load($this->pid); + islandora_do_derivatives($islandora_object, array( + 'force' => TRUE, + )); + $this->assertEqual('modifyDatastream', $ingest_method, 'The expected ingest method is "modifyDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('FORCEFULLY APPENDING CONTENT TO test', $islandora_object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO test", got "' . $islandora_object['DERIV']->content . '".'); + } + + public function testDerivativeOnForceNonExistingDatastream() { + global $ingest_method; + $ingest_method = 'modifyDatastream'; + $this->constructBaseObject(); + $object = islandora_object_load($this->pid); + islandora_do_derivatives($object, array( + 'force' => TRUE, + )); + $this->assertEqual('ingestDatastream', $ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('FORCEFULLY APPENDING CONTENT TO test', $object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO test", got "' . $object['DERIV']->content . '".'); + } + + public function testDerivativeOnModifyExistingDatastream() { + global $ingest_method; + $ingest_method = 'ingestDatastream'; + $object = $this->constructBaseObject(); + $this->constructDERIVDatastream($object); + $connection = islandora_get_tuque_connection(); + $connection->cache->resetCache(); + $islandora_object = islandora_object_load($this->pid); + $changed_content = 'islandora beast'; + $islandora_object['OBJ']->content = $changed_content; + $this->assertEqual('modifyDatastream', $ingest_method, 'The expected ingest method is "modifyDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('FORCEFULLY APPENDING CONTENT TO ' . $changed_content, $islandora_object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO islandora beast", got "' . $islandora_object['DERIV']->content . '".'); + } + + public function testDerivativeOnModifyNonExistingDatastream() { + global $ingest_method; + $ingest_method = 'modifyDatastream'; + $this->constructBaseObject(); + // Need to do this as Tuque caches. + $connection = islandora_get_tuque_connection(); + $connection->cache->resetCache(); + $islandora_object = islandora_object_load($this->pid); + $changed_content = 'islandora beast'; + $islandora_object['OBJ']->content = $changed_content; + $this->assertEqual('ingestDatastream', $ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('FORCEFULLY APPENDING CONTENT TO ' . $changed_content, $islandora_object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO islandora beast", got "' . $islandora_object['DERIV']->content . '".'); + } + + public function testDerivativeFilteringOnSourceDSID() { + global $derivative_functions; + $derivative_functions = array(); + $this->constructBaseObject(); + $object = islandora_object_load($this->pid); + islandora_do_derivatives($object, array( + 'source_dsid' => 'OBJ', + )); + $this->assertEqual(1, count($derivative_functions), 'Expected 1 derivative function for the source_dsid of "OBJ", got ' . count($derivative_functions) . '.'); + $called_function = (string) reset($derivative_functions); + $this->assertEqual('islandora_derivatives_test_create_deriv_datastream', $called_function, 'Expected derivative function is "islandora_derivatives_test_create_deriv_datastream", got "' . $called_function . '".'); + + // Reset the derivative functions array as we are going to use it again. + $derivative_functions = array(); + islandora_do_derivatives($object, array( + 'source_dsid' => 'SOMEWEIRDDATASTREAM', + )); + $this->assertEqual(1, count($derivative_functions), 'Expected 1 derivative function for the source_dsid of "SOMEWEIRDDATASTREAM", got ' . count($derivative_functions) . '.'); + $called_function = (string) reset($derivative_functions); + $this->assertEqual('islandora_derivatives_test_create_some_weird_datastream', $called_function, 'Expected derivative function is "islandora_derivatives_test_create_some_weird_datastream", got "' . $called_function . '".'); + } + + /** + * Helper function that will construct a base object. + */ + public function constructBaseObject() { + $object = $this->repository->constructObject($this->pid); + $object->models = array( + 'some:cmodel', + ); + $dsid = 'OBJ'; + $ds = $object->constructDatastream($dsid); + $ds->label = 'Test'; + $ds->content = 'test'; + $object->ingestDatastream($ds); + $this->repository->ingestObject($object); + return $object; + } + + public function constructDERIVDatastream(AbstractObject $object) { + $dsid = 'DERIV'; + $ds = $object->constructDatastream($dsid); + $ds->label = 'Test'; + $ds->content = 'test'; + $object->ingestDatastream($ds); + return $object; + } + + } + diff --git a/tests/islandora_derivatives_test.info b/tests/islandora_derivatives_test.info new file mode 100644 index 00000000..338b39fe --- /dev/null +++ b/tests/islandora_derivatives_test.info @@ -0,0 +1,7 @@ +name = Islandora Derivatives Generation testing +description = Tests derivative generation hooks. Do not enable. +core = 7.x +package = Testing +hidden = TRUE +files[] = islandora_derivatives_test.module +dependencies[] = islandora diff --git a/tests/islandora_derivatives_test.module b/tests/islandora_derivatives_test.module new file mode 100644 index 00000000..36b6380c --- /dev/null +++ b/tests/islandora_derivatives_test.module @@ -0,0 +1,114 @@ + 'OBJ', + 'destination_dsid' => 'DERIV', + 'weight' => '0', + 'function' => array( + 'islandora_derivatives_test_create_deriv_datastream', + ), + ), + array( + 'source_dsid' => 'SOMEWEIRDDATASTREAM', + 'destination_dsid' => 'STANLEY', + 'weight' => '-1', + 'function' => array( + 'islandora_derivatives_test_create_some_weird_datastream', + ), + ), + ); +} + +function islandora_derivatives_test_create_deriv_datastream(AbstractObject $object, $force = FALSE) { + global $derivative_functions; + $derivative_functions[] = 'islandora_derivatives_test_create_deriv_datastream'; + $return = ''; + if (!isset($object['DERIV']) || (isset($object['DERIV']) && $force === TRUE)) { + if ($force !== TRUE) { + $deriv_string = $object['OBJ']->content . ' some string'; + } + else { + $deriv_string = "FORCEFULLY APPENDING CONTENT TO " . $object['OBJ']->content; + } + $added_successfully = islandora_derivatives_test_add_datastream($object, 'DERIV', $deriv_string); + if ($added_successfully !== TRUE) { + $return = islandora_derivatives_test_failed_adding($added_successfully); + } + else { + $return = array( + 'success' => TRUE, + 'messages' => array( + array( + 'message' => t('The DERIV datastream was added successfully for @pid!'), + 'message_sub' => array('@pid' => $object->id), + 'type' => WATCHDOG_INFO, + ), + ), + ); + } + return $return; + } +} + +/** + * Stub function that should never actually get called because of DSID filtering. + * + * @param AbstractObject $object + * An AbstractObject representing a Fedora object. + * @param bool $force + * Whether the derivatives are being forcefully generated or not. + */ +function islandora_derivatives_test_create_some_weird_datastream(AbstractObject $object, $force = FALSE) { + global $derivative_functions; + // Add to the global that we got to this function. + $derivative_functions[] = 'islandora_derivatives_test_create_some_weird_datastream'; +} + +function islandora_derivatives_test_add_datastream(AbstractObject $object, $dsid, $deriv_string) { + global $ingest_method; + try { + $ingest = !isset($object[$dsid]); + if ($ingest) { + $ds = $object->constructDatastream($dsid, 'M'); + $ds->label = $dsid; + } + else { + $ds = $object[$dsid]; + } + $ds->content = $deriv_string; + if ($ingest) { + $ingest_method = 'ingestDatastream'; + $object->ingestDatastream($ds); + } + else { + $ingest_method = 'modifyDatastream'; + } + return TRUE; + } + catch (exception $e) { + $message = $e->getMessage(); + return $message; + } +} + +function islandora_derivatives_test_failed_adding($message) { + return array( + 'success' => FALSE, + 'messages' => array( + array( + 'message' => $message, + 'type' => WATCHDOG_ERROR, + ), + ), + ); +} \ No newline at end of file From 82da5d74ff3c526f6bd89f4270da130c8fb66e66 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 7 Aug 2013 18:34:30 +0000 Subject: [PATCH 3/6] Restructuring to the derivate process, documentation, more tests. --- includes/derivatives.inc | 101 ++++++++++++++ islandora.api.php | 72 ++++++++++ islandora.module | 81 ++++-------- tests/derivatives.test | 169 ++++++++++++++++++++---- tests/islandora_derivatives_test.module | 112 ++++++++++++++-- 5 files changed, 438 insertions(+), 97 deletions(-) create mode 100644 includes/derivatives.inc diff --git a/includes/derivatives.inc b/includes/derivatives.inc new file mode 100644 index 00000000..f5058588 --- /dev/null +++ b/includes/derivatives.inc @@ -0,0 +1,101 @@ + FALSE, + ); + $hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array()); + uasort($hooks, 'drupal_sort_weight'); + $results = array(); + + if (array_key_exists('source_dsid', $options)) { + $hooks = array_filter($hooks, function($filter_hook) use($options) { + return array_key_exists('source_dsid', $filter_hook) && + $filter_hook['source_dsid'] == $options['source_dsid']; + }); + } + + if (array_key_exists('destination_dsid', $options)) { + $hooks = array_filter($hooks, function($filter_hook) use($options) { + return array_key_exists('destination_dsid', $filter_hook) && + $filter_hook['destination_dsid'] == $options['destination_dsid']; + }); + } + + foreach ($hooks as $hook) { + if (isset($hook['file'])) { + require_once $hook['file']; + } + foreach ($hook['function'] as $function) { + $logging = call_user_func($function, $object, $options['force']); + if (!empty($logging)) { + $results[] = $logging; + } + } + } + return $results; +} + +/** + * Handles the logging of derivative messages. + * + * @param array $logging_results + * An array of messages describing the outcome of the derivative events. + * Each individual message array has the following structure: + * - success: Bool denoting whether the operation was successful. + * - messages: An array structure containing: + * - message: A string passed through t() describing the + * outcome of the operation. + * - message_sub: (Optional) Substitutions to be passed along to t() or + * watchdog. + * - type: A string denoting whether the output is to be + * drupal_set_messaged (dsm) or watchdogged (watchdog). + * - severity: (Optional) A severity level / status to be used when + * logging messages. Uses the defaults of drupal_set_message and + * watchdog if not defined. + */ +function islandora_derivative_logging(array $logging_results) { + foreach ($logging_results as $result) { + foreach ($result['messages'] as $message) { + if ($message['type'] === 'dsm') { + drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array()), isset($message['severity']) ? $message['severity'] : 'status')); + } + else { + watchdog('islandora', $message['message'], isset($message['message_sub']) ? $message['message_sub'] : array(), isset($message['severity']) ? $message['severity'] : WATCHDOG_NOTICE); + } + } + } +} diff --git a/islandora.api.php b/islandora.api.php index 129787f4..74bdef81 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -519,3 +519,75 @@ function hook_islandora_datastream_access($op, $object, $user) { */ function hook_CMODEL_PID_islandora_datastream_access($op, $object, $user) { } + +/** + * Defines derivative functions to be executed based on certain conditions. + * + * This hook fires when an object/datastream is ingested or a datastream is + * modified. + * + * @return array + * An array containing an entry for each derivative to be created. Each entry + * is an array of parameters containing: + * - force: Bool denoting whether we are forcing the generation of + * derivatives. + * - source_dsid: (Optional) String of the datastream id we are generating + * from or NULL if it's the object itself. + * - destination_dsid: (Optional) String of the datastream id that is being + * created. To be used in the UI. + * - weight: A string denoting the weight of the function. This value is + * sorted upon to run functions in order. + * - function: An array of function(s) to be ran when constructing + * derivatives. Functions that are defined to be called for derivation + * creation must have the following structure: + * module_name_derivative_creation_function($object, $force = FALSE) + * These functions must return an array in the structure of: + * - success: Bool denoting whether the operation was successful. + * - messages: An array structure containing: + * - message: A string passed through t() describing the + * outcome of the operation. + * - message_sub: (Optional) Substitutions to be passed along to t() or + * watchdog. + * - type: A string denoting whether the output is to be + * drupal_set_messaged (dsm) or watchdogged (watchdog). + * - severity: (Optional) A severity level / status to be used when + * logging messages. Uses the defaults of drupal_set_message and + * watchdog if not defined. + */ +function hook_islandora_derivative() { + return array( + array( + 'source_dsid' => 'OBJ', + 'destination_dsid' => 'DERIV', + 'weight' => '0', + 'function' => array( + 'islandora_derivatives_test_create_deriv_datastream', + ), + ), + array( + 'source_dsid' => 'SOMEWEIRDDATASTREAM', + 'destination_dsid' => 'STANLEY', + 'weight' => '-1', + 'function' => array( + 'islandora_derivatives_test_create_some_weird_datastream', + ), + ), + array( + 'source_dsid' => NULL, + 'destination_dsid' => 'NOSOURCE', + 'weight' => '-3', + 'function' => array( + 'islandora_derivatives_test_create_nosource_datastream', + ), + ), + ); +} + +/** + * Content model specific version of hook_islandora_derivative(). + * + * @see hook_islandora_derivative() + */ +function hook_CMODEL_PID_islandora_derivative() { + +} \ No newline at end of file diff --git a/islandora.module b/islandora.module index 989dd36e..9bec87c7 100644 --- a/islandora.module +++ b/islandora.module @@ -1417,10 +1417,30 @@ function islandora_islandora_basic_collection_get_query_filters() { } } + +/** + * Implements hook_islandora_object_ingested(). + * + * On object ingestion we call the case of source_dsid being NULL only as + * the islandora_islandora_datastream_ingested hook will handle the cases + * where specific values of source_dsid can occur. + */ +function islandora_islandora_object_ingested(AbstractObject $object) { + module_load_include('inc', 'islandora', 'includes/derivatives'); + $logging_results = islandora_do_derivatives($object, array( + 'source_dsid' => NULL, + )); + islandora_derivative_logging($logging_results); +} + /** * Implements hook_islandora_datastream_ingested(). + * + * When a datastream is ingested we filter the derivatives on source_dsid being + * equal to the current ingested datastream's id. */ function islandora_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) { + module_load_include('inc', 'islandora', 'includes/derivatives'); $logging_results = islandora_do_derivatives($object, array( 'source_dsid' => $datastream->id, )); @@ -1429,67 +1449,16 @@ function islandora_islandora_datastream_ingested(AbstractObject $object, Abstrac /** * Implements hook_islandora_datastream_modified(). + * + * When a datastream is modified we filter the derivatives on source_dsid being + * equal to the current ingested datastream's id. Force is set to TRUE such that + * existing derivatives will be updated to reflect the change in the source. */ function islandora_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) { + module_load_include('inc', 'islandora', 'includes/derivatives'); $logging_results = islandora_do_derivatives($object, array( 'source_dsid' => $datastream->id, 'force' => TRUE, )); islandora_derivative_logging($logging_results); } - -function islandora_do_derivatives(AbstractObject $object, array $options = array()) { - $options += array( - 'force' => FALSE, - 'source_dsid' => NULL, - 'destination_dsid' => NULL, - ); - $hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array()); - uasort($hooks, 'drupal_sort_weight'); - $results = array(); - - if ($options['source_dsid'] !== NULL) { - $hooks = array_filter($hooks, function($filter_hook) use($options) { - return !isset($filter_hook['source_dsid']) || - (isset($filter_hook['source_dsid']) && $filter_hook['source_dsid'] == $options['source_dsid']); - }); - } - if ($options['destination_dsid'] !== NULL) { - $hooks = array_filter($hooks, function($filter_hook) use($options) { - return !isset($filter_hook['destination_dsid']) || - (isset($filter_hook['destination_dsid']) && $filter_hook['destination_dsid'] == $options['destination_dsid']); - }); - } - dd($hooks, 'hooooooks'); - foreach ($hooks as $hook) { - if (isset($hook['file'])) { - require_once $hook['file']; - } - foreach ($hook['function'] as $function) { - $logging = call_user_func($function, $object, $options['force']); - if (!empty($logging)) { - $results[] = $logging; - } - } - } - return $results; -} - -function islandora_derivative_logging(array $logging_results) { - foreach ($logging_results as $result) { - foreach ($result['messages'] as $message) { - if ($message['type'] >= WATCHDOG_WARNING) { - if ($message['type'] == WATCHDOG_WARNING) { - $status = 'warning'; - } - else { - $status = 'status'; - } - drupal_set_message(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array()), $status); - } - else { - watchdog('islandora', $message['message'], isset($message['message_sub']) ? $message['message_sub'] : array(), $message['type']); - } - } - } -} \ No newline at end of file diff --git a/tests/derivatives.test b/tests/derivatives.test index a98753f7..13014880 100644 --- a/tests/derivatives.test +++ b/tests/derivatives.test @@ -34,7 +34,7 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase { public function setUp() { parent::setUp( array( - 'islandora_derivatives_test', + 'islandora_derivatives_test', ) ); $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); @@ -56,9 +56,12 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase { parent::tearDown(); } + /** + * Tests that the islandora_islandora_object_ingested hook gets fired. + */ public function testDerivativeOnIngest() { - global $ingest_method; - $ingest_method = 'modifyDatastream'; + global $_islandora_derivative_test_ingest_method; + $_islandora_derivative_test_ingest_method = 'modifyDatastream'; $tuque = islandora_get_tuque_connection(); $object = $tuque->repository->constructObject($this->pid); $object->models = array( @@ -75,53 +78,70 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase { 'DC', 'OBJ', 'DERIV', + 'NOSOURCE', )); - $this->assertEqual('ingestDatastream', $ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('ingestDatastream', $_islandora_derivative_test_ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $_islandora_derivative_test_ingest_method . '".'); $this->assertEqual('test some string', $object['DERIV']->content, 'The expected content of the DERIV datastream is "test some string", got "' . $object['DERIV']->content . '".'); + $this->assertEqual('NOSOURCE', $object['NOSOURCE']->content, 'The expected content of the NOSOURCE datastream is "NOSOURCE", got "' . $object['NOSOURCE']->content . '".'); + } - public function testDerivativeOnForceExistingDatastream() { - global $ingest_method; - $ingest_method = 'ingestDatastream'; + /** + * Tests the ingest method when when forcing on existing datastreams. + */ + public function testDerivativeOnForceExistingDatastream() { + global $_islandora_derivative_test_ingest_method; + $_islandora_derivative_test_ingest_method = 'ingestDatastream'; $object = $this->constructBaseObject(); - $this->constructDERIVDatastream($object); + $object = $this->constructDERIVDatastream($object); + $this->constructNOSOURCEDatastream($object); $islandora_object = islandora_object_load($this->pid); islandora_do_derivatives($islandora_object, array( 'force' => TRUE, )); - $this->assertEqual('modifyDatastream', $ingest_method, 'The expected ingest method is "modifyDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('modifyDatastream', $_islandora_derivative_test_ingest_method, 'The expected ingest method is "modifyDatastream", got "' . $_islandora_derivative_test_ingest_method . '".'); $this->assertEqual('FORCEFULLY APPENDING CONTENT TO test', $islandora_object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO test", got "' . $islandora_object['DERIV']->content . '".'); } + /** + * Tests the ingest method when forcing on non-existing datastreams. + */ public function testDerivativeOnForceNonExistingDatastream() { - global $ingest_method; - $ingest_method = 'modifyDatastream'; + global $_islandora_derivative_test_ingest_method; + $_islandora_derivative_test_ingest_method = 'modifyDatastream'; $this->constructBaseObject(); $object = islandora_object_load($this->pid); islandora_do_derivatives($object, array( 'force' => TRUE, )); - $this->assertEqual('ingestDatastream', $ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $ingest_method . '".'); - $this->assertEqual('FORCEFULLY APPENDING CONTENT TO test', $object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO test", got "' . $object['DERIV']->content . '".'); + $this->assertEqual('ingestDatastream', $_islandora_derivative_test_ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $_islandora_derivative_test_ingest_method . '".'); + $this->assertEqual('test some string', $object['DERIV']->content, 'The expected content of the DERIV datastream is "test some string", got "' . $object['DERIV']->content . '".'); } + /** + * Tests the islandora_datastream_modified hook when there are existing DSes. + */ public function testDerivativeOnModifyExistingDatastream() { - global $ingest_method; - $ingest_method = 'ingestDatastream'; + global $_islandora_derivative_test_ingest_method; + $_islandora_derivative_test_ingest_method = 'ingestDatastream'; $object = $this->constructBaseObject(); $this->constructDERIVDatastream($object); + // Need to do this as Tuque caches. $connection = islandora_get_tuque_connection(); $connection->cache->resetCache(); $islandora_object = islandora_object_load($this->pid); $changed_content = 'islandora beast'; $islandora_object['OBJ']->content = $changed_content; - $this->assertEqual('modifyDatastream', $ingest_method, 'The expected ingest method is "modifyDatastream", got "' . $ingest_method . '".'); + $this->assertEqual('modifyDatastream', $_islandora_derivative_test_ingest_method, 'The expected ingest method is "modifyDatastream", got "' . $_islandora_derivative_test_ingest_method . '".'); $this->assertEqual('FORCEFULLY APPENDING CONTENT TO ' . $changed_content, $islandora_object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO islandora beast", got "' . $islandora_object['DERIV']->content . '".'); } + /** + * Tests islandora_datastream_modified hook when there are no existing DSes. + */ public function testDerivativeOnModifyNonExistingDatastream() { - global $ingest_method; - $ingest_method = 'modifyDatastream'; + global $_islandora_derivative_test_ingest_method; + $_islandora_derivative_test_ingest_method = 'modifyDatastream'; $this->constructBaseObject(); // Need to do this as Tuque caches. $connection = islandora_get_tuque_connection(); @@ -129,32 +149,98 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase { $islandora_object = islandora_object_load($this->pid); $changed_content = 'islandora beast'; $islandora_object['OBJ']->content = $changed_content; - $this->assertEqual('ingestDatastream', $ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $ingest_method . '".'); - $this->assertEqual('FORCEFULLY APPENDING CONTENT TO ' . $changed_content, $islandora_object['DERIV']->content, 'The expected content of the DERIV datastream is "FORCEFULLY APPENDING CONTENT TO islandora beast", got "' . $islandora_object['DERIV']->content . '".'); + $this->assertEqual('ingestDatastream', $_islandora_derivative_test_ingest_method, 'The expected ingest method is "ingestDatastream", got "' . $_islandora_derivative_test_ingest_method . '".'); + $this->assertEqual($changed_content . ' some string', $islandora_object['DERIV']->content, 'The expected content of the DERIV datastream is "islandora beast string", got "' . $islandora_object['DERIV']->content . '".'); } + /** + * Tests derivative hook filtering based upon source_dsid. + */ public function testDerivativeFilteringOnSourceDSID() { - global $derivative_functions; - $derivative_functions = array(); + global $_islandora_derivative_test_derivative_functions; + $_islandora_derivative_test_derivative_functions = array(); $this->constructBaseObject(); $object = islandora_object_load($this->pid); islandora_do_derivatives($object, array( 'source_dsid' => 'OBJ', )); - $this->assertEqual(1, count($derivative_functions), 'Expected 1 derivative function for the source_dsid of "OBJ", got ' . count($derivative_functions) . '.'); - $called_function = (string) reset($derivative_functions); + $this->assertEqual(1, count($_islandora_derivative_test_derivative_functions), 'Expected 1 derivative function for the source_dsid of "OBJ", got ' . count($_islandora_derivative_test_derivative_functions) . '.'); + $called_function = (string) reset($_islandora_derivative_test_derivative_functions); $this->assertEqual('islandora_derivatives_test_create_deriv_datastream', $called_function, 'Expected derivative function is "islandora_derivatives_test_create_deriv_datastream", got "' . $called_function . '".'); // Reset the derivative functions array as we are going to use it again. - $derivative_functions = array(); + $_islandora_derivative_test_derivative_functions = array(); islandora_do_derivatives($object, array( 'source_dsid' => 'SOMEWEIRDDATASTREAM', )); - $this->assertEqual(1, count($derivative_functions), 'Expected 1 derivative function for the source_dsid of "SOMEWEIRDDATASTREAM", got ' . count($derivative_functions) . '.'); - $called_function = (string) reset($derivative_functions); + $this->assertEqual(1, count($_islandora_derivative_test_derivative_functions), 'Expected 1 derivative function for the source_dsid of "SOMEWEIRDDATASTREAM", got ' . count($_islandora_derivative_test_derivative_functions) . '.'); + $called_function = (string) reset($_islandora_derivative_test_derivative_functions); $this->assertEqual('islandora_derivatives_test_create_some_weird_datastream', $called_function, 'Expected derivative function is "islandora_derivatives_test_create_some_weird_datastream", got "' . $called_function . '".'); } + /** + * Tests that only functions were the source_dsid is NULL are fired. + */ + public function testNULLSourceDSID() { + global $_islandora_derivative_test_derivative_functions; + $_islandora_derivative_test_derivative_functions = array(); + $this->constructBaseObject(); + $object = islandora_object_load($this->pid); + islandora_do_derivatives($object, array( + 'source_dsid' => NULL, + )); + $this->assertDatastreams($object, array( + 'DC', + 'RELS-EXT', + 'OBJ', + 'NOSOURCE', + )); + $this->assertEqual(1, count($_islandora_derivative_test_derivative_functions), 'Expected 1 derivative function for the source_dsid of "NULL", got ' . count($_islandora_derivative_test_derivative_functions) . '.'); + $called_function = (string) reset($_islandora_derivative_test_derivative_functions); + $this->assertEqual('islandora_derivatives_test_create_nosource_datastream', $called_function, 'Expected derivative function is "islandora_derivatives_test_create_nosource_datastream", got "' . $called_function . '".'); + $this->assertEqual('NOSOURCE', $object['NOSOURCE']->content, 'The expected content of the NOSOURCE datastream is "NOSOURCE", got "' . $object['NOSOURCE']->content . '".'); + } + + /** + * Tests that when no source_dsid all derivative functions are called. + */ + public function testNoSourceDSIDNoForce() { + global $_islandora_derivative_test_derivative_functions; + $_islandora_derivative_test_derivative_functions = array(); + $this->constructBaseObject(); + $object = islandora_object_load($this->pid); + islandora_do_derivatives($object, array()); + $this->assertDatastreams($object, array( + 'DC', + 'RELS-EXT', + 'OBJ', + 'DERIV', + 'NOSOURCE', + )); + $this->assertEqual(3, count($_islandora_derivative_test_derivative_functions), 'Expected 3 derivative functions when there is no source_dsid, got ' . count($_islandora_derivative_test_derivative_functions) . '.'); + } + + /** + * Tests that when no source_dsid all derivative functions are called. + */ + public function testNoSourceDSIDForce() { + global $_islandora_derivative_test_derivative_functions; + $_islandora_derivative_test_derivative_functions = array(); + $this->constructBaseObject(); + $object = islandora_object_load($this->pid); + islandora_do_derivatives($object, array( + 'force' => TRUE, + )); + $this->assertDatastreams($object, array( + 'DC', + 'RELS-EXT', + 'OBJ', + 'DERIV', + 'NOSOURCE', + )); + $this->assertEqual(3, count($_islandora_derivative_test_derivative_functions), 'Expected 3 derivative functions when there is no source_dsid, got ' . count($_islandora_derivative_test_derivative_functions) . '.'); + } + /** * Helper function that will construct a base object. */ @@ -172,14 +258,39 @@ class IslandoraDerivativesTestCase extends IslandoraWebTestCase { return $object; } + /** + * Helper function to construct the DERIV datastream without firing hooks. + * + * @param AbstractObject $object + * An AbstractObject representing a FedoraObject. + * + * @return AbstractObject + * The modified AbstractObject. + */ public function constructDERIVDatastream(AbstractObject $object) { $dsid = 'DERIV'; $ds = $object->constructDatastream($dsid); $ds->label = 'Test'; - $ds->content = 'test'; + $ds->content = 'test some string'; $object->ingestDatastream($ds); return $object; } + /** + * Helper function to construct the NOSOURCE datastream without firing hooks. + * + * @param AbstractObject $object + * An AbstractObject representing a FedoraObject. + * + * @return AbstractObject + * The modified AbstractObject. + */ + public function constructNOSOURCEDatastream(AbstractObject $object) { + $dsid = 'NOSOURCE'; + $ds = $object->constructDatastream($dsid); + $ds->label = 'Test'; + $ds->content = 'NOSOURCE'; + $object->ingestDatastream($ds); + return $object; } - +} diff --git a/tests/islandora_derivatives_test.module b/tests/islandora_derivatives_test.module index 36b6380c..71e043f0 100644 --- a/tests/islandora_derivatives_test.module +++ b/tests/islandora_derivatives_test.module @@ -26,15 +26,35 @@ function islandora_derivatives_test_some_cmodel_islandora_derivative() { 'islandora_derivatives_test_create_some_weird_datastream', ), ), + array( + 'source_dsid' => NULL, + 'destination_dsid' => 'NOSOURCE', + 'weight' => '-3', + 'function' => array( + 'islandora_derivatives_test_create_nosource_datastream', + ), + ), ); } +/** + * Creates the DERIV datastream for use in testing. + * + * @param AbstractObject $object + * An AbstractObject representing a Fedora object. + * @param bool $force + * Whether or not derivative generation is to be forced. + * @return array + * An array detailing the success of the operation. + * + * @see hook_islandora_derivative() + */ function islandora_derivatives_test_create_deriv_datastream(AbstractObject $object, $force = FALSE) { - global $derivative_functions; - $derivative_functions[] = 'islandora_derivatives_test_create_deriv_datastream'; + global $_islandora_derivative_test_derivative_functions; + $_islandora_derivative_test_derivative_functions[] = 'islandora_derivatives_test_create_deriv_datastream'; $return = ''; if (!isset($object['DERIV']) || (isset($object['DERIV']) && $force === TRUE)) { - if ($force !== TRUE) { + if ($force !== TRUE || !isset($object['DERIV'])) { $deriv_string = $object['OBJ']->content . ' some string'; } else { @@ -51,7 +71,7 @@ function islandora_derivatives_test_create_deriv_datastream(AbstractObject $obje array( 'message' => t('The DERIV datastream was added successfully for @pid!'), 'message_sub' => array('@pid' => $object->id), - 'type' => WATCHDOG_INFO, + 'type' => 'dsm', ), ), ); @@ -61,7 +81,7 @@ function islandora_derivatives_test_create_deriv_datastream(AbstractObject $obje } /** - * Stub function that should never actually get called because of DSID filtering. + * Stub function that used only for datastream filtering counts. * * @param AbstractObject $object * An AbstractObject representing a Fedora object. @@ -69,13 +89,69 @@ function islandora_derivatives_test_create_deriv_datastream(AbstractObject $obje * Whether the derivatives are being forcefully generated or not. */ function islandora_derivatives_test_create_some_weird_datastream(AbstractObject $object, $force = FALSE) { - global $derivative_functions; + global $_islandora_derivative_test_derivative_functions; // Add to the global that we got to this function. - $derivative_functions[] = 'islandora_derivatives_test_create_some_weird_datastream'; + $_islandora_derivative_test_derivative_functions[] = 'islandora_derivatives_test_create_some_weird_datastream'; } +/** + * Creates the NOSOURCE datastream for use in testing. + * + * @param AbstractObject $object + * An AbstractObject representing a Fedora object. + * @param bool $force + * Whether or not derivative generation is to be forced. + * @return array + * An array detailing the success of the operation. + * + * @see hook_islandora_derivative() + */ +function islandora_derivatives_test_create_nosource_datastream(AbstractObject $object, $force = FALSE) { + global $_islandora_derivative_test_derivative_functions; + $_islandora_derivative_test_derivative_functions[] = 'islandora_derivatives_test_create_nosource_datastream'; + $return = ''; + if (!isset($object['NOSOURCE']) || (isset($object['NOSOURCE']) && $force === TRUE)) { + if ($force !== TRUE || !isset($object['NOSOURCE'])) { + $deriv_string = 'NOSOURCE'; + } + else { + $deriv_string = "FORCEFULLY APPENDING CONTENT TO " . $object['NOSOURCE']->content; + } + $added_successfully = islandora_derivatives_test_add_datastream($object, 'NOSOURCE', $deriv_string); + if ($added_successfully !== TRUE) { + $return = islandora_derivatives_test_failed_adding($added_successfully); + } + else { + $return = array( + 'success' => TRUE, + 'messages' => array( + array( + 'message' => t('The DERIV datastream was added successfully for @pid!'), + 'message_sub' => array('@pid' => $object->id), + 'type' => 'dsm', + ), + ), + ); + } + return $return; + } +} + +/** + * Helper function that adds/modifies the datastream to the object in testing. + * + * @param AbstractObject $object + * An AbstractObject representing a Fedora object. + * @param string $dsid + * The datastream id for which we are adding/modifying. + * @param string $deriv_string + * The content of the datastream we are adding. + * + * @return bool|string + * A bool if the operation was successfully, the error message otherwise. + */ function islandora_derivatives_test_add_datastream(AbstractObject $object, $dsid, $deriv_string) { - global $ingest_method; + global $_islandora_derivative_test_ingest_method; try { $ingest = !isset($object[$dsid]); if ($ingest) { @@ -87,11 +163,11 @@ function islandora_derivatives_test_add_datastream(AbstractObject $object, $dsid } $ds->content = $deriv_string; if ($ingest) { - $ingest_method = 'ingestDatastream'; + $_islandora_derivative_test_ingest_method = 'ingestDatastream'; $object->ingestDatastream($ds); } else { - $ingest_method = 'modifyDatastream'; + $_islandora_derivative_test_ingest_method = 'modifyDatastream'; } return TRUE; } @@ -101,14 +177,26 @@ function islandora_derivatives_test_add_datastream(AbstractObject $object, $dsid } } +/** + * Returns a message if we failed to add a derivative. + * + * @see hook_islandora_derivative() + * + * @param string $message + * The error message to be returned back. + * + * @return array + * An array describing the outcome of our failure. + */ function islandora_derivatives_test_failed_adding($message) { return array( 'success' => FALSE, 'messages' => array( array( 'message' => $message, - 'type' => WATCHDOG_ERROR, + 'type' => 'watchdog', + 'severity' => WATCHDOG_ERROR, ), ), ); -} \ No newline at end of file +} From 69010df8ea04d8c895b27363cbdab3970a7246c1 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 7 Aug 2013 19:06:09 +0000 Subject: [PATCH 4/6] Filter xssing too much, minor doc fixes. --- includes/derivatives.inc | 2 +- islandora.api.php | 4 +++- tests/islandora_derivatives_test.module | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index f5058588..f707f88a 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -91,7 +91,7 @@ function islandora_derivative_logging(array $logging_results) { foreach ($logging_results as $result) { foreach ($result['messages'] as $message) { if ($message['type'] === 'dsm') { - drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array()), isset($message['severity']) ? $message['severity'] : 'status')); + drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), isset($message['severity']) ? $message['severity'] : 'status'); } else { watchdog('islandora', $message['message'], isset($message['message_sub']) ? $message['message_sub'] : array(), isset($message['severity']) ? $message['severity'] : WATCHDOG_NOTICE); diff --git a/islandora.api.php b/islandora.api.php index 74bdef81..da6dae77 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -553,6 +553,8 @@ function hook_CMODEL_PID_islandora_datastream_access($op, $object, $user) { * - severity: (Optional) A severity level / status to be used when * logging messages. Uses the defaults of drupal_set_message and * watchdog if not defined. + * - file: A string denoting the path to the file where the function + * is being called from. */ function hook_islandora_derivative() { return array( @@ -590,4 +592,4 @@ function hook_islandora_derivative() { */ function hook_CMODEL_PID_islandora_derivative() { -} \ No newline at end of file +} diff --git a/tests/islandora_derivatives_test.module b/tests/islandora_derivatives_test.module index 71e043f0..80530296 100644 --- a/tests/islandora_derivatives_test.module +++ b/tests/islandora_derivatives_test.module @@ -6,7 +6,7 @@ */ /** - * Implements hook_islandora_CMODEL_derivative(). + * Implements hook_islandora_CMODEL_PID_derivative(). */ function islandora_derivatives_test_some_cmodel_islandora_derivative() { return array( @@ -146,7 +146,7 @@ function islandora_derivatives_test_create_nosource_datastream(AbstractObject $o * The datastream id for which we are adding/modifying. * @param string $deriv_string * The content of the datastream we are adding. - * + * * @return bool|string * A bool if the operation was successfully, the error message otherwise. */ From 0b53c36cea67c814a641851e8dc81b9ae0d1a22c Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Thu, 8 Aug 2013 18:06:55 +0000 Subject: [PATCH 5/6] Coding standards ignore. --- includes/derivatives.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index f707f88a..67979d4a 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -94,7 +94,11 @@ function islandora_derivative_logging(array $logging_results) { drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), isset($message['severity']) ? $message['severity'] : 'status'); } else { + // @codingStandardsIgnoreStart + // We know what we are doing here. Passing through the translated + // message and the substitutions needed. watchdog('islandora', $message['message'], isset($message['message_sub']) ? $message['message_sub'] : array(), isset($message['severity']) ? $message['severity'] : WATCHDOG_NOTICE); + // @codingStandardsIgnoreEnd } } } From a0fc2179da3cb212d88e78dc66bdd3a043631e3d Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Thu, 8 Aug 2013 18:45:36 +0000 Subject: [PATCH 6/6] Coder hackery. --- includes/derivatives.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index 67979d4a..4a422535 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -94,11 +94,11 @@ function islandora_derivative_logging(array $logging_results) { drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), isset($message['severity']) ? $message['severity'] : 'status'); } else { - // @codingStandardsIgnoreStart // We know what we are doing here. Passing through the translated - // message and the substitutions needed. - watchdog('islandora', $message['message'], isset($message['message_sub']) ? $message['message_sub'] : array(), isset($message['severity']) ? $message['severity'] : WATCHDOG_NOTICE); - // @codingStandardsIgnoreEnd + // message and the substitutions needed. We are using + // call_user_func until such time as the @ignore changes + // are merged into the standard release for Coder. + call_user_func('watchdog', $message['message'], isset($message['message_sub']) ? $message['message_sub'] : array(), isset($message['severity']) ? $message['severity'] : WATCHDOG_NOTICE); } } }