summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery_task.php4
-rw-r--r--modules/gallery/helpers/graphics.php33
2 files changed, 24 insertions, 13 deletions
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index 4d6de3ba..3a705027 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -19,7 +19,7 @@
*/
class gallery_task_Core {
static function available_tasks() {
- $dirty_count = graphics::find_dirty_images_query()->count();
+ $dirty_count = graphics::find_dirty_images_query()->count_records();
$tasks = array();
$tasks[] = Task_Definition::factory()
->callback("gallery_task::rebuild_dirty_images")
@@ -47,7 +47,7 @@ class gallery_task_Core {
static function rebuild_dirty_images($task) {
$errors = array();
try {
- $result = graphics::find_dirty_images_query();
+ $result = graphics::find_dirty_images_query()->select("id")->execute();
$total_count = $task->get("total_count", $result->count());
$mode = $task->get("mode", "init");
if ($mode == "init") {
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index c93cc304..6fab0b54 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -197,11 +197,22 @@ class graphics_Core {
* @return Database_Result Query result
*/
static function find_dirty_images_query() {
- return Database::instance()->query(
- "SELECT `id` FROM {items} " .
- "WHERE ((`thumb_dirty` = 1 AND (`type` <> 'album' OR `album_cover_item_id` IS NOT NULL))" .
- " OR (`resize_dirty` = 1 AND `type` = 'photo')) " .
- " AND `id` != 1");
+ return db::build()
+ ->from("items")
+ ->and_open()
+ ->and_open()
+ ->where("thumb_dirty", "=", 1)
+ ->and_open()
+ ->where("type", "<>", "album")
+ ->or_where("album_cover_item_id", "IS NOT", null)
+ ->close()
+ ->or_open()
+ ->where("resize_dirty", "=", 1)
+ ->where("type", "=", "photo")
+ ->close()
+ ->close()
+ ->where("id", "<>", 1)
+ ->close();
}
/**
@@ -209,18 +220,18 @@ class graphics_Core {
*/
static function mark_dirty($thumbs, $resizes) {
if ($thumbs || $resizes) {
- $db = Database::instance();
- $fields = array();
+ $db = db::build()
+ ->update("items");
if ($thumbs) {
- $fields["thumb_dirty"] = 1;
+ $db->set("thumb_dirty", 1);
}
if ($resizes) {
- $fields["resize_dirty"] = 1;
+ $db->set("resize_dirty", 1);
}
- $db->update("items", $fields, true);
+ $db->execute();
}
- $count = self::find_dirty_images_query()->count();
+ $count = self::find_dirty_images_query()->count_records();
if ($count) {
site_status::warning(
t2("One of your photos is out of date. <a %attrs>Click here to fix it</a>",