Closed ThomasDaheim closed 8 years ago
More info:
This seems to happen because I have a category with this name twice in piwigo: one from uploading and one from converting to virtual later on. I show use the virtual one but the link in the osm map is to the intial, uploaded one. Seems like the SQL to look up the images/categories doesn't use the current category id correctly/not at all?
Getting closer... In functions_map.php the query is using "i.storage_category_id" to create the imageurl to be used as link in the popup:
$query="SELECT i.latitude, i.longitude,
IFNULL(i.name, '') AS `name`,
IF(i.representative_ext IS NULL,
CONCAT(SUBSTRING_INDEX(TRIM(LEADING '.' FROM i.path), '.', 1 ), '-sq.', SUBSTRING_INDEX(TRIM(LEADING '.' FROM i.path), '.', -1 )),
TRIM(LEADING '.' FROM
REPLACE(i.path, TRIM(TRAILING '.' FROM SUBSTRING_INDEX(i.path, '/', -1 )),
CONCAT('pwg_representative/',
CONCAT(
TRIM(TRAILING '.' FROM SUBSTRING_INDEX( SUBSTRING_INDEX(i.path, '/', -1 ) , '.', 1 )),
CONCAT('-sq.', i.representative_ext)
)
)
)
)
) AS `pathurl`,
TRIM(TRAILING '/' FROM CONCAT( i.id, '/category/', IFNULL(i.storage_category_id, '') ) ) AS `imgurl`,
IFNULL(i.comment, '') AS `comment`,
IFNULL(i.author, '') AS `author`,
i.width
FROM ".IMAGES_TABLE." AS i
INNER JOIN (".IMAGE_CATEGORY_TABLE." AS ic ".$INNER_JOIN.") ON i.id = ic.image_id
WHERE ".$LIMIT_SEARCH." i.latitude IS NOT NULL AND i.longitude IS NOT NULL ".$forbidden." GROUP BY i.id;";
And that gives another result as the link that is used for the list of thumbs below the map!
Which lead to this quick-hack to use the category of the page if set:
// TF, 20151111
// use category of $page['category']['id'] if available
$usecategory = "IFNULL(i.storage_category_id, '')";
if (isset($page['category']) and isset($page['category']['id']) and strlen(($page['category']['id'])>0))
{
$usecategory = $page['category']['id'];
}
$query="SELECT i.latitude, i.longitude,
IFNULL(i.name, '') AS `name`,
IF(i.representative_ext IS NULL,
CONCAT(SUBSTRING_INDEX(TRIM(LEADING '.' FROM i.path), '.', 1 ), '-sq.', SUBSTRING_INDEX(TRIM(LEADING '.' FROM i.path), '.', -1 )),
TRIM(LEADING '.' FROM
REPLACE(i.path, TRIM(TRAILING '.' FROM SUBSTRING_INDEX(i.path, '/', -1 )),
CONCAT('pwg_representative/',
CONCAT(
TRIM(TRAILING '.' FROM SUBSTRING_INDEX( SUBSTRING_INDEX(i.path, '/', -1 ) , '.', 1 )),
CONCAT('-sq.', i.representative_ext)
)
)
)
)
) AS `pathurl`,
TRIM(TRAILING '/' FROM CONCAT( i.id, '/category/', ".$usecategory." ) ) AS `imgurl`,
IFNULL(i.comment, '') AS `comment`,
IFNULL(i.author, '') AS `author`,
i.width
FROM ".IMAGES_TABLE." AS i
INNER JOIN (".IMAGE_CATEGORY_TABLE." AS ic ".$INNER_JOIN.") ON i.id = ic.image_id
WHERE ".$LIMIT_SEARCH." i.latitude IS NOT NULL AND i.longitude IS NOT NULL ".$forbidden." GROUP BY i.id;";
Well above is only a quick-hack that works in some cases. Root cause of the issue is that i.storage_category_id isn't OK to use since it might be in the list of categories returned by get_sql_condition_FandF! Better to use the result of the inner join to the category table where the $forbidden categories are filtered out...
And here is the solution to use the INNER JOIN result:
Use ic.category_id instead of i.storage_category_id as category for creating the imgurl
Pull request created for fix
Thanks for all the analyze and pointing the bug. Pull request #85 merged. Fully merger via #86
Your welcome
It seems like this issue got "re-introduced" - at least I had the problem in 2.8a and was able to fix it by changing the relevant line in functions_map.php
Hi,
when looking at an album on my site (e.g. http://www.feuster.com/piwigo/index.php?/category/651) and clicking on a marker in the map to show a thumb I can see that the link created is incorrect:
http://www.feuster.com/piwigo/picture.php?/6675/category/630
where it should be
http://www.feuster.com/piwigo/picture.php?/6675/category/651
Note, that in the map the incorrect category is used in the link! A quick scan indicates that this happens in all albums.
In idea how to fix this?
Thanks, Thomas