summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/access.php33
-rw-r--r--modules/gallery/helpers/gallery_block.php2
-rw-r--r--modules/gallery/helpers/gallery_rss.php1
-rw-r--r--modules/gallery/helpers/gallery_task.php20
-rw-r--r--modules/gallery/helpers/graphics.php3
-rw-r--r--modules/gallery/helpers/l10n_client.php1
-rw-r--r--modules/gallery/helpers/module.php3
7 files changed, 40 insertions, 23 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 10fa8666..29b981e8 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -663,23 +663,28 @@ class access_Core {
* working and our permission system works.
*/
static function htaccess_works() {
- $success_url = url::file("var/tmp/security_test/success");
+ $success_url = url::file("var/security_test/success");
- @mkdir(VARPATH . "tmp/security_test");
- if ($fp = @fopen(VARPATH . "tmp/security_test/.htaccess", "w+")) {
- fwrite($fp, "RewriteEngine On\n");
- fwrite($fp, "RewriteRule verify $success_url [L]\n");
- fclose($fp);
- }
+ @mkdir(VARPATH . "security_test");
+ try {
+ if ($fp = @fopen(VARPATH . "security_test/.htaccess", "w+")) {
+ fwrite($fp, "RewriteEngine On\n");
+ fwrite($fp, "RewriteRule verify $success_url [L]\n");
+ fclose($fp);
+ }
- if ($fp = @fopen(VARPATH . "tmp/security_test/success", "w+")) {
- fwrite($fp, "success");
- fclose($fp);
- }
+ if ($fp = @fopen(VARPATH . "security_test/success", "w+")) {
+ fwrite($fp, "success");
+ fclose($fp);
+ }
- list ($response) = remote::do_request(url::abs_file("var/tmp/security_test/verify"));
- $works = $response == "HTTP/1.1 200 OK";
- @dir::unlink(VARPATH . "tmp/security_test");
+ list ($response) = remote::do_request(url::abs_file("var/security_test/verify"));
+ $works = $response == "HTTP/1.1 200 OK";
+ } catch (Exception $e) {
+ @dir::unlink(VARPATH . "security_test");
+ throw $e;
+ }
+ @dir::unlink(VARPATH . "security_test");
return $works;
}
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php
index 9d4e81b6..be0f11b8 100644
--- a/modules/gallery/helpers/gallery_block.php
+++ b/modules/gallery/helpers/gallery_block.php
@@ -72,7 +72,7 @@ class gallery_block_Core {
$block->content = new View("admin_block_platform.html");
if (is_readable("/proc/loadavg")) {
$block->content->load_average =
- join(" ", array_slice(explode(" ", array_shift(file("/proc/loadavg"))), 0, 3));
+ join(" ", array_slice(explode(" ", current(file("/proc/loadavg"))), 0, 3));
} else {
$block->content->load_average = t("Unavailable");
}
diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php
index d422636f..c1790d28 100644
--- a/modules/gallery/helpers/gallery_rss.php
+++ b/modules/gallery/helpers/gallery_rss.php
@@ -25,6 +25,7 @@ class gallery_rss_Core {
}
static function feed($feed_id, $offset, $limit, $id) {
+ $feed = new stdClass();
switch ($feed_id) {
case "latest":
$feed->children = ORM::factory("item")
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index c75e050a..3e6278e5 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -40,7 +40,7 @@ class gallery_task_Core {
$tasks[] = Task_Definition::factory()
->callback("gallery_task::file_cleanup")
->name(t("Remove old files"))
- ->description(t("Remove files from the logs and tmp directory"))
+ ->description(t("Remove expired files from the logs and tmp directory"))
->severity(log::SUCCESS);
return $tasks;
}
@@ -111,6 +111,7 @@ class gallery_task_Core {
site_status::clear("graphics_dirty");
}
} catch (Exception $e) {
+ Kohana_Log::add("error",(string)$e);
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
@@ -214,6 +215,7 @@ class gallery_task_Core {
Cache::instance()->delete("update_l10n_cache:{$task->id}");
}
} catch (Exception $e) {
+ Kohana_Log::add("error",(string)$e);
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
@@ -233,13 +235,13 @@ class gallery_task_Core {
try {
$start = microtime(true);
$data = Cache::instance()->get("file_cleanup_cache:{$task->id}");
- if ($data) {
- $files = unserialize($data);
- }
+ $files = $data ? unserialize($data) : array();
$i = 0;
+ $current = 0;
+ $total = 0;
switch ($task->get("mode", "init")) {
- case "init": // 0%
+ case "init":
$threshold = time() - 1209600; // older than 2 weeks
foreach(array("logs", "tmp") as $dir) {
$dir = VARPATH . $dir;
@@ -262,6 +264,7 @@ class gallery_task_Core {
if (count($files) == 0) {
break;
}
+
case "delete_files":
$current = $task->get("current");
$total = $task->get("total");
@@ -273,14 +276,17 @@ class gallery_task_Core {
$task->set("current", $current);
}
- $task->status = t("Removed: %count files. Total: %total_count.",
- array("count" => $current, "total_count" => $total));
+ $task->status = t2("Removed: 1 file. Total: %total_count.",
+ "Removed: %count files. Total: %total_count.",
+ $current, array("total_count" => $total));
if ($total == $current) {
$task->done = true;
$task->state = "success";
+ $task->percent_complete = 100;
}
} catch (Exception $e) {
+ Kohana_Log::add("error",(string)$e);
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 5a290905..c85c7750 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -262,6 +262,9 @@ class graphics_Core {
*/
static function detect_toolkits() {
$toolkits = new stdClass();
+ $toolkits->gd = new stdClass();
+ $toolkits->imagemagick = new stdClass();
+ $toolkits->graphicsmagick = new stdClass();
// GD is special, it doesn't use exec()
$gd = function_exists("gd_info") ? gd_info() : array();
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index 086245e8..c27e4e5b 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -77,6 +77,7 @@ class l10n_client_Core {
* translations for.
*/
static function fetch_updates(&$num_fetched) {
+ $request = new stdClass();
$request->locales = array();
$request->messages = new stdClass();
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 95e426c4..9523d1d2 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -430,7 +430,8 @@ class module_Core {
// This could happen if there's a race condition
continue;
}
- self::$var_cache->{$row->module_name}->{$row->name} = $row->value;
+ // Mute the "Creating default object from empty value" warning below
+ @self::$var_cache->{$row->module_name}->{$row->name} = $row->value;
}
$cache = ORM::factory("var");
$cache->module_name = "gallery";