From 686da5a3e069d180e198fcc8dc3e2ed422f725b9 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 18 May 2010 06:16:47 -0700 Subject: [PATCH] Save the item before updating the order of the children. Also always increment the weight count (even if it is equal to the weight of the current child) --- modules/gallery/helpers/item_rest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 36d2ca6211..298c2f4adc 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -126,18 +126,19 @@ static function put($request) { } } } + $item->save(); - $weight = 0; if (isset($request->params->members)) { + $weight = 0; foreach ($request->params->members as $url) { $child = rest::resolve($url); if ($child->parent_id == $item->id && $child->weight != $weight) { - $child->weight = $weight++; + $child->weight = $weight; $child->save(); } + $weight++; } } - $item->save(); } static function post($request) {