As discussed on https://piwigo.org/forum/viewtopic.php?id=28338 we have a problem on high volume galleries when an upload is running and each photo is uploaded very quickly. The problem comes from the cache regeneration.
In include/user.inc.php we already have:
$user = build_user( $user['id'],
( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
);
Meaning we avoided to regenerate cache if we were in the administration. That was perfectly valid when we didn't use the API to upload photos. Now that we use pwg.images.upload (and other methods) we skip this IN_ADMIN test and the cache is regenerated each time we call ws.php. We should replace it with something like:
$use_cache = true;
if (defined('IN_ADMIN') and IN_ADMIN)
{
$use_cache = false;
}
if (isset($_REQUEST['method']) and 'pwg.images.upload' == $_REQUEST['method'])
{
$use_cache = false;
}
$user = build_user( $user['id'], $use_cache);
As discussed on https://piwigo.org/forum/viewtopic.php?id=28338 we have a problem on high volume galleries when an upload is running and each photo is uploaded very quickly. The problem comes from the cache regeneration.
In `include/user.inc.php` we already have:
```
$user = build_user( $user['id'],
( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
);
```
Meaning we avoided to regenerate cache if we were in the administration. That was perfectly valid when we didn't use the API to upload photos. Now that we use `pwg.images.upload` (and other methods) we skip this `IN_ADMIN` test and the cache is regenerated each time we call `ws.php`. We should replace it with something like:
```
$use_cache = true;
if (defined('IN_ADMIN') and IN_ADMIN)
{
$use_cache = false;
}
if (isset($_REQUEST['method']) and 'pwg.images.upload' == $_REQUEST['method'])
{
$use_cache = false;
}
$user = build_user( $user['id'], $use_cache);
```
<!-- github-sync-id:833021121 -->
The test shows a problem. During Community upload, the first photo is correctly uploaded, but on next photo:
Warning: [mysql error 1064] You have an error in your SQL syntax;
AND level > 8
AND level <= 8
GROUP BY category_id' at line 5
SELECT
category_id
FROM image_category
JOIN images ON image_id = id
WHERE category_id IN ()
AND level > 8
AND level <= 8
GROUP BY category_id
; in include/dblayer/functions_mysqli.inc.php on line 856
The test shows a problem. During Community upload, the first photo is correctly uploaded, but on next photo:
```
Warning: [mysql error 1064] You have an error in your SQL syntax;
AND level > 8
AND level <= 8
GROUP BY category_id' at line 5
SELECT
category_id
FROM image_category
JOIN images ON image_id = id
WHERE category_id IN ()
AND level > 8
AND level <= 8
GROUP BY category_id
; in include/dblayer/functions_mysqli.inc.php on line 856
```
<!-- github-comment-id:801768219 -->
I don't know how easy it is to do, but, if the website were to use the ws api under the hood, this would have the effect of both having a single code base to test and maintain, and keep the ws api fully featured.
I don't know how easy it is to do, but, if the website were to use the ws api under the hood, this would have the effect of both having a single code base to test and maintain, and keep the ws api fully featured.
<!-- github-comment-id:801870752 -->
I think we need to go deeper on this experiment and try to change Community to keep the idea of not rebuilding cache each time we do a pure admin task like an upload.
I think we need to go deeper on this experiment and try to change Community to keep the idea of not rebuilding cache each time we do a pure admin task like an upload.
<!-- github-comment-id:845742180 -->
With the lounge we already have a nice optimization.
For now and the immediate future, I don't see any easy way to reduce user cache resets. I postpone to 15 the "in depth" brainstorm to make things better.
With the lounge we already have a nice optimization.
For now and the immediate future, I don't see any easy way to reduce user cache resets. I postpone to 15 the "in depth" brainstorm to make things better.
<!-- github-comment-id:1751684850 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
As discussed on https://piwigo.org/forum/viewtopic.php?id=28338 we have a problem on high volume galleries when an upload is running and each photo is uploaded very quickly. The problem comes from the cache regeneration.
In
include/user.inc.phpwe already have:Meaning we avoided to regenerate cache if we were in the administration. That was perfectly valid when we didn't use the API to upload photos. Now that we use
pwg.images.upload(and other methods) we skip thisIN_ADMINtest and the cache is regenerated each time we callws.php. We should replace it with something like:I'm currently testing it on a few Piwigo.com servers :-)
The test shows a problem. During Community upload, the first photo is correctly uploaded, but on next photo:
I don't know how easy it is to do, but, if the website were to use the ws api under the hood, this would have the effect of both having a single code base to test and maintain, and keep the ws api fully featured.
I think we need to go deeper on this experiment and try to change Community to keep the idea of not rebuilding cache each time we do a pure admin task like an upload.
With the lounge we already have a nice optimization.
For now and the immediate future, I don't see any easy way to reduce user cache resets. I postpone to 15 the "in depth" brainstorm to make things better.
Following #2335 we could have a more comprehensive list of API method that does not trigger user_cache rebuild.