summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gallery/helpers/gallery.php8
-rw-r--r--modules/gallery/helpers/gallery_theme.php4
-rw-r--r--modules/gallery/libraries/MY_Database.php3
-rw-r--r--modules/rest/helpers/rest.php2
4 files changed, 14 insertions, 3 deletions
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 38002b58..725a710d 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -214,4 +214,12 @@ class gallery_Core {
}
return null;
}
+
+ /**
+ * Return true if we should show the profiler at the bottom of the page. Note that this
+ * function is called at database setup time so it cannot rely on the database.
+ */
+ static function show_profiler() {
+ return file_exists(VARPATH . "PROFILE");
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index f94b9ecd..3c6d71e9 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -71,7 +71,7 @@ class gallery_theme_Core {
static function page_bottom($theme) {
$session = Session::instance();
- if ($session->get("profiler", false)) {
+ if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();
@@ -96,7 +96,7 @@ class gallery_theme_Core {
static function admin_page_bottom($theme) {
$session = Session::instance();
- if ($session->get("profiler", false)) {
+ if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();
diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php
index 604b6484..aae0bb79 100644
--- a/modules/gallery/libraries/MY_Database.php
+++ b/modules/gallery/libraries/MY_Database.php
@@ -32,6 +32,9 @@ abstract class Database extends Database_Core {
$config["connection"]["params"] = null;
}
parent::__construct($config);
+ if (gallery::show_profiler()) {
+ $this->config['benchmark'] = true;
+ }
}
/**
diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php
index eeedff2a..9b367feb 100644
--- a/modules/rest/helpers/rest.php
+++ b/modules/rest/helpers/rest.php
@@ -54,7 +54,7 @@ class rest_Core {
$html = t("Empty response");
}
print "<pre>$html</pre>";
- if (Session::instance()->get("profiler", false)) {
+ if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();