summaryrefslogtreecommitdiff
path: root/modules/gallery/models/item.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/models/item.php')
-rw-r--r--modules/gallery/models/item.php16
1 files changed, 2 insertions, 14 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 481b22bc..dcbee991 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -350,21 +350,9 @@ class Item_Model extends ORM_MPTT {
if (!empty($this->changed) && $this->changed != array("view_count" => "view_count")) {
$this->updated = time();
if (!$this->loaded) {
- try {
$this->created = $this->updated;
- Kohana::log("error", "get Weight");
- $weight = ORM::factory("item")
- ->select("weight")
- ->orderby("weight", "DESC")
- ->limit(1)
- ->find_all()
- ->current()->weight;
- Kohana::log("error", "Weight: $weight");
- $this->weight = $weight + 1;
- } catch (Exception $e) {
- Kohana::log("error", $e->__toString());
- throw $e;
- }
+ $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find();
+ $this->weight = $r->max_weight + 1;
} else {
$send_event = 1;
}