mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-05-12 03:16:24 +03:00
fixes #348 force logical album sort order
This way we can safely remove empty albums without decrementing count_categories twice.
This commit is contained in:
parent
5579b1e1a3
commit
195791c4e2
1 changed files with 6 additions and 0 deletions
|
@ -491,6 +491,7 @@ SELECT image_id
|
||||||
function get_computed_categories(&$userdata, $filter_days=null)
|
function get_computed_categories(&$userdata, $filter_days=null)
|
||||||
{
|
{
|
||||||
$query = 'SELECT c.id AS cat_id, id_uppercat';
|
$query = 'SELECT c.id AS cat_id, id_uppercat';
|
||||||
|
$query.= ', global_rank';
|
||||||
// Count by date_available to avoid count null
|
// Count by date_available to avoid count null
|
||||||
$query .= ',
|
$query .= ',
|
||||||
MAX(date_available) AS date_last, COUNT(date_available) AS nb_images
|
MAX(date_available) AS date_last, COUNT(date_available) AS nb_images
|
||||||
|
@ -533,6 +534,11 @@ FROM '.CATEGORIES_TABLE.' as c
|
||||||
$cats[$row['cat_id']] = $row;
|
$cats[$row['cat_id']] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it is important to logically sort the albums because some operations
|
||||||
|
// (like removal) rely on this logical order. Child album doesn't always
|
||||||
|
// have a bigger id than its parent (if it was moved afterwards).
|
||||||
|
uasort($cats, 'global_rank_compare');
|
||||||
|
|
||||||
foreach ($cats as $cat)
|
foreach ($cats as $cat)
|
||||||
{
|
{
|
||||||
if ( !isset( $cat['id_uppercat'] ) )
|
if ( !isset( $cat['id_uppercat'] ) )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue