aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/functions.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2012-07-25 10:20:40 +0000
committerplegall <plg@piwigo.org>2012-07-25 10:20:40 +0000
commit60d23d4f611ccca73a3c1efd51933d8097bc59c5 (patch)
tree58721e58a225e3d913ddf0e371c7f4c32c3b16e4 /admin/include/functions.php
parentc382e4c8659f595218432f9ee824e5542a89de6f (diff)
merge r17001 from branch 2.4 to trunk
bug 2627 fixed: photos added with the web form or pwg.images.addSimple now have a correct image_category.rank. git-svn-id: http://piwigo.org/svn/trunk@17002 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/functions.php')
-rw-r--r--admin/include/functions.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 85295e472..93453715b 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1507,16 +1507,40 @@ DELETE
;';
pwg_query($query);
+ $query = '
+SELECT
+ category_id,
+ MAX(rank) AS max_rank
+ FROM '.IMAGE_CATEGORY_TABLE.'
+ WHERE rank IS NOT NULL
+ AND category_id IN ('.implode(',', $categories).')
+ GROUP BY category_id
+;';
+
+ $current_rank_of = simple_hash_from_query(
+ $query,
+ 'category_id',
+ 'max_rank'
+ );
+
$inserts = array();
foreach ($categories as $category_id)
{
+ if (!isset($current_rank_of[$category_id]))
+ {
+ $current_rank_of[$category_id] = 0;
+ }
+
foreach ($images as $image_id)
{
+ $rank = ++$current_rank_of[$category_id];
+
array_push(
$inserts,
array(
'image_id' => $image_id,
'category_id' => $category_id,
+ 'rank' => $rank,
)
);
}
@@ -2341,6 +2365,7 @@ function clear_derivative_cache_rec($path, $pattern)
function delete_element_derivatives($infos, $type='all')
{
+file_put_contents('/tmp/pwg24ws.log', "\n==== ".date('c')."\n".__FUNCTION__.' : '.var_export($infos, true)."\n", FILE_APPEND);
$path = $infos['path'];
if (!empty($infos['representative_ext']))
{