From a788cc52a0d9f83deb047e57ac0d79b530612ac0 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Wed, 4 Mar 2015 13:40:01 -0400 Subject: [PATCH] Allowing more object altering in hooks. --- includes/tuque_wrapper.inc | 6 ++++-- tests/includes/utilities.inc | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/tuque_wrapper.inc b/includes/tuque_wrapper.inc index d14a86b3..f5044db0 100644 --- a/includes/tuque_wrapper.inc +++ b/includes/tuque_wrapper.inc @@ -276,8 +276,10 @@ class IslandoraFedoraApiM extends FedoraApiM { ); islandora_alter_datastream($object, $datastream, $context); $params = $context['params']; - if (isset($params['lastModifiedDate'])) { - $params['lastModifiedDate'] = (string) $object[$dsid]->createdDate; + // Anything may be altered during the alter_datastream hook invocation so + // we need to update our time to the change we know about. + if (isset($params['lastModifiedDate']) && $params['lastModifiedDate'] < (string) $object->lastModifiedDate) { + $params['lastModifiedDate'] = (string) $object->lastModifiedDate; } if ($context['block']) { throw new Exception('Modify Datastream was blocked.'); diff --git a/tests/includes/utilities.inc b/tests/includes/utilities.inc index 4eef5255..eefae4cc 100644 --- a/tests/includes/utilities.inc +++ b/tests/includes/utilities.inc @@ -315,7 +315,7 @@ class IslandoraTestUtilities extends IslandoraTestUtilityClass { * * @return bool * TRUE if all objects were removed, or FALSE if any of them still remained - * after removal. + * after removal. */ public function deleteUserCreatedObjects($username) { if ($username === $this->configuration['admin_user']) {