From 5db38dde915f091fbafa1b8eca24ab42d60b2b6c Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Mon, 18 Jun 2012 15:29:22 +0200 Subject: [PATCH] Use drupal set headers to allow proper page caching, but disable caching... Noticed at first that it wasn't working, and then it made the DB huge... Anyway. --- ObjectHelper.inc | 14 +++++++------- fedora_repository.module | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 25dd8c53..c757fae6 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -186,7 +186,7 @@ class ObjectHelper { //Set what headers we can... if ($mimeType = $info['content_type']) { - header("Content-Type: $mimeType"); + drupal_set_header("Content-Type: $mimeType"); if ($asAttachment) { $suggestedFileName = "$label"; @@ -212,7 +212,7 @@ class ObjectHelper { $suggestedFileName = "$label.$ext"; } - header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); + drupal_set_header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); } } @@ -227,14 +227,14 @@ class ObjectHelper { unset($query['q']); } - header('HTTP/1.1 307 Moved Temporarily'); - header('Location: ' . url($effective_url, array('query' => $query))); + drupal_set_header('HTTP/1.1 307 Moved Temporarily'); + drupal_set_header('Location: ' . url($effective_url, array('query' => $query))); } elseif ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { //If not anonymous, soap is force or we're using HTTPS //Have the webserver mediate the transfer (download and restream) if (($contentSize = self::getDatastreamSize($pid, $dsID, TRUE)) > 0) { - header("Content-Length: $contentSize"); + drupal_set_header("Content-Length: $contentSize"); } $opts = array( @@ -253,8 +253,8 @@ class ObjectHelper { } } else { //Try to redirect directly to Fedora. - header('HTTP/1.1 307 Moved Temporarily'); - header('Location: ' . $url); + drupal_set_header('HTTP/1.1 307 Moved Temporarily'); + drupal_set_header('Location: ' . $url); } } else { diff --git a/fedora_repository.module b/fedora_repository.module index 8642de9c..e66c6ce0 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -994,10 +994,10 @@ function fedora_repository_islandora_tabs($content_models, $pid, $page_number) { //can disable showing the object details tab in admin UI if (variable_get('fedora_repository_show_object_details_tab', TRUE)) { $object_details = $obj->showFieldSets(); - $cmodel_tabs = array_merge($cmodels_tabs, $object_details); + $cmodels_tabs = array_merge($cmodels_tabs, $object_details); } - return array_merge($cmodels_tabs, $object_details); + return $cmodels_tabs; } /** @@ -1159,6 +1159,8 @@ function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { drupal_set_message(t("no pid or dsid given to create an object with!")); return ' '; } + //Disable the page cache, so entire datastreams do not get thrown into the page cache. + $GLOBALS['conf']['cache'] = FALSE; $objectHelper = new ObjectHelper(); $objectHelper->makeObject($pid, $dsId, TRUE, $label, FALSE, $version);