From e560c90520bbacab56e04ecb1dedb55a8521005e Mon Sep 17 00:00:00 2001 From: willtp87 Date: Fri, 28 Mar 2014 11:16:20 -0300 Subject: [PATCH 1/8] doc clarification and mentioning new clean up practice --- islandora.api.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/islandora.api.php b/islandora.api.php index e8b45ba7..062e96e6 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -627,11 +627,14 @@ function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object * - 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. + * from or NULL if it's the object itself. Does not impact function + * ordering. * - destination_dsid: (Optional) String of the datastream id that is being - * created. To be used in the UI. + * created. To be used in the UI. Does not impact function ordering. * - weight: A string denoting the weight of the function. This value is - * sorted upon to run functions in order. + * sorted upon to run functions in order. Some derivation steps operate as + * clean up steps. For consistency with ingest steps they use weight:50 it + * is advisable to stay beneath this weight. * - 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: From 27e2f5f978a18cc2387924208d747ff0b43110e5 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Mon, 31 Mar 2014 11:20:24 -0300 Subject: [PATCH 2/8] letting batch derivitives run during batches --- includes/derivatives.inc | 22 ++++++++++++++++++++++ islandora.module | 10 ++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index d25789cc..5c0c3dd7 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -4,6 +4,28 @@ * Defines functions used when constructing derivatives. */ +/** + * Decides which derivative function to call and runs it. + * + * @param AbstractObject $object + * The object to run the derivative function for. + * @param string $dsid + * The DSID to run the derivative function for. + */ +function islandora_run_derivatives (AbstractObject $object, $dsid) { + if (empty(batch_get())) { + $logging_results = islandora_do_derivatives($object, array( + 'source_dsid' => $dsid, + )); + islandora_derivative_logging($logging_results); + } + else { + islandora_do_batch_derivatives($object, array( + 'source_dsid' => $dsid, + )); + } +} + /** * Kicks off derivative functions based upon hooks and conditions. * diff --git a/islandora.module b/islandora.module index 9e7809eb..94b34e93 100644 --- a/islandora.module +++ b/islandora.module @@ -1695,10 +1695,7 @@ function islandora_islandora_basic_collection_get_query_filters() { */ 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); + islandora_run_derivatives($object, NULL); } /** @@ -1709,10 +1706,7 @@ function islandora_islandora_object_ingested(AbstractObject $object) { */ 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, - )); - islandora_derivative_logging($logging_results); + islandora_run_derivatives($object, $datastream->id); } /** From f3e8f797a4dfea5d01c8cca917e14adad5de393b Mon Sep 17 00:00:00 2001 From: willtp87 Date: Wed, 16 Apr 2014 13:05:55 -0300 Subject: [PATCH 3/8] abandoning 50 --- islandora.api.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/islandora.api.php b/islandora.api.php index cd68b2be..5b79e540 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -632,9 +632,7 @@ function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object * - destination_dsid: (Optional) String of the datastream id that is being * created. To be used in the UI. Does not impact function ordering. * - weight: A string denoting the weight of the function. This value is - * sorted upon to run functions in order. Some derivation steps operate as - * clean up steps. For consistency with ingest steps they use weight:50 it - * is advisable to stay beneath this weight. + * 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: From 8855039955d52c0d7946829629869d442e5cb8a0 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Wed, 16 Apr 2014 13:26:08 -0300 Subject: [PATCH 4/8] can not send a function to empty --- includes/derivatives.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index 2576f1a5..64042a69 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -13,7 +13,8 @@ * The DSID to run the derivative function for. */ function islandora_run_derivatives (AbstractObject $object, $dsid) { - if (empty(batch_get())) { + $batch_array = batch_get(); + if (empty($batch_array)) { $logging_results = islandora_do_derivatives($object, array( 'source_dsid' => $dsid, )); From 219a9fae9087056856d8b9dc16ac0a965616caae Mon Sep 17 00:00:00 2001 From: willtp87 Date: Mon, 21 Apr 2014 15:09:06 -0300 Subject: [PATCH 5/8] handling NULL source_dsids in datastream_access hook --- islandora.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/islandora.module b/islandora.module index 4d8a7e4d..d6ac826a 100644 --- a/islandora.module +++ b/islandora.module @@ -1874,7 +1874,8 @@ function islandora_islandora_datastream_access($op, AbstractDatastream $datastre $hooks = islandora_invoke_hook_list(ISLANDORA_DERVIATIVE_CREATION_HOOK, $object->models, array($object)); $hooks = islandora_filter_derivatives($hooks, array('force' => TRUE), $object); foreach ($hooks as $hook) { - if ($hook['destination_dsid'] == $datastream->id && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$hook['source_dsid']], $user)) { + if ($hook['destination_dsid'] == $datastream->id && + (is_null($hook['source_dsid']) || islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$hook['source_dsid']], $user))) { $applicable_hook = TRUE; break; } From dee9362b3b283ed67623b43810739f49fec4e9f2 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Mon, 21 Apr 2014 15:34:17 -0300 Subject: [PATCH 6/8] not implying we pass it through t --- islandora.api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/islandora.api.php b/islandora.api.php index 5b79e540..159806cb 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -643,7 +643,7 @@ function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object * following fields: * - message: A string passed through t() describing the * outcome of the operation. - * - message_sub: (Optional) Substitutions to be passed along to t() or + * - message_sub: (Optional) A substitution array as acceptable by t() or * watchdog. * - type: A string denoting whether the output is to be * drupal_set_messaged (dsm) or watchdogged (watchdog). From 311fae0f64cc93fe9c5d3a7f85785dddc2e213fa Mon Sep 17 00:00:00 2001 From: willtp87 Date: Mon, 21 Apr 2014 15:43:40 -0300 Subject: [PATCH 7/8] coder --- includes/derivatives.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index 64042a69..281d87d9 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -12,7 +12,7 @@ * @param string $dsid * The DSID to run the derivative function for. */ -function islandora_run_derivatives (AbstractObject $object, $dsid) { +function islandora_run_derivatives(AbstractObject $object, $dsid) { $batch_array = batch_get(); if (empty($batch_array)) { $logging_results = islandora_do_derivatives($object, array( From 3f4cdaea9dd7ef3a092e2a6238c28184af6978bb Mon Sep 17 00:00:00 2001 From: willtp87 Date: Tue, 22 Apr 2014 17:34:26 -0300 Subject: [PATCH 8/8] derivatives in batches so derivatives that need to batch can run --- includes/derivatives.inc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index 281d87d9..47ec4fad 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -21,9 +21,25 @@ function islandora_run_derivatives(AbstractObject $object, $dsid) { islandora_derivative_logging($logging_results); } else { - islandora_do_batch_derivatives($object, array( - 'source_dsid' => $dsid, - )); + batch_set( + // Title won't show for batch in a batch. + array( + 'init_message' => t('Preparing derivatives for @label', array('@label' => $object->label)), + 'error_message' => t('An error occured creating derivatives.'), + 'progress_message' => t( + 'Creating derivatives for @label
Time elapsed: @elapsed
+ Estimated time remaining @estimate.', + array('@label' => $object->label) + ), + 'file' => drupal_get_path('module', 'islandora') . '/includes/regenerate_derivatives.form.inc', + 'operations' => islandora_do_batch_derivatives( + $object, + array( + 'source_dsid' => $dsid, + ) + ), + ) + ); } }