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
This commit is contained in:
plegall 2012-07-25 10:20:40 +00:00
parent c382e4c865
commit 60d23d4f61

View file

@ -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']))
{