this is a newer error customer reports, over last 2 months
2 posts by 2 authors in: Forums > CMS Builder
Last Post: Friday at 3:42pm (RSS)
While I did recently update this client's cmsb version (to 3.84), he says he's had this challenge for about 2 months (version 2.77). Sometimes, not every time, when he's uploading a lot of images at one time the browser/system hangs and locks up. Initially I put it off as a glitch, or the hosting company at those times was running tight on resources or had some temp issue. It just happened again, about an hour ago, but the error on the backend seems a little different than past ones so I'm writing in to see if there's something that can be done.
On the error list page (modified for privacy/security):
#135579 - Unable to remove file '/home/xxxxxx/public_html/images/uploads/thumb2/35-img-6665-jpg.webp' Please ask your server administrator to check permissions on that file and directory. The PHP error message was: unlink(/home/xxxxxx/public_html/images/uploads/thumb2/35-img-6665-jpg.webp): No such file or directory
/home/xxxxxx/public_html/cmsuAMGP383/lib/upload_functions.php:679
POST https://xxxxxxxxxx.com/cmsuAMGP383/admin.php
and inside the details of the error, the mention of the "upload strategy" file caught my attention:
Backtrace
#0 Script started at /home/xxxxxx/public_html/cmsuAMGP383/admin.php:0 #1 require() at /home/xxxxxx/public_html/cmsuAMGP383/admin.php:82 #2 require() at /home/xxxxxx/public_html/cmsuAMGP383/lib/menus/default/actionHandler.php:106 #3 require() at /home/xxxxxx/public_html/cmsuAMGP383/lib/menus/default/uploadForm.php:4 #4 submitUploadForm() at /home/xxxxxx/public_html/cmsuAMGP383/lib/menus/default/uploadForm_functions.php:24 #5 removeExpiredUploads() at /home/xxxxxx/public_html/cmsuAMGP383/lib/menus/default/uploadForm_functions.php:38 #6 DefaultUploadStorageStrategy->removeUploadsForRecord() at /home/xxxxxx/public_html/cmsuAMGP383/lib/upload_functions.php:679 #7 RuntimeException thrown at /home/xxxxxx/public_html/cmsuAMGP383/lib/upload_storage_strategy.php:130 -> Unable to remove file '/home/xxxxxx/public_html/images/uploads/thumb2/35-img-6665-jpg.webp' Please ask your server administrator to check permissions on that file and directory. The PHP error message was: unlink(/home/xxxxxx/public_html/images/uploads/thumb2/35-img-6665-jpg.webp): No such file or directory
and
RAW LOG DATA:
errfile => "/home/xxxxxx/public_html/cmsuAMGP383/lib/upload_storage_strategy.php"
errline => 130
errno => "RuntimeException"
errstr => "Unable to remove file '/home/xxxxxx/public_html/images/uploads/thumb2/35-img-6665-jpg.webp'\n\nPlease ask your server administrator to check permissions on that file and directory.\n\nThe PHP error message was: unlink(/home/xxxxxx/public_html/images/uploads/thumb2/35-img-6665-jpg.webp): No such file or directory\n"
exceptionClass => "RuntimeException"
exceptionCode => 0
externalFilePath => "/home/xxxxxx/public_html/cmsuAMGP383/lib/upload_functions.php"
externalLineNum => 679
logType => "exception"
So I am just wondering (because I'm still a programming neophyte) if the "upload strategy" file has some limiter in this case, or something? Or is it just a challenge with the hosts' resources?
It seems when he's uploading around 100 images at one time it occurs, and if he has a problem, he gets around it uploading 20 at a time (but it drives him crazy). I will mention here that there was a similar challenge that was worked out several years ago and he does have a plugin (built by IT) for resorting the images after saving.
Thank you for your attention to this.
By Dave - Friday at 3:42pm
Hi Codee,
Thanks for the report! We tracked this down, and it's a timing issue with bulk uploads, not a permissions problem or an upload limit.
Two things are going on:
- The upload form doesn't limit how many files it sends at once. Browsers used to cap this at about 6 requests per server, but on newer hosting with HTTP/2 that cap is gone, so dropping 100 images can start 100 uploads at the same time. Each one is a separate server process resizing images into thumbnails, and 100 of those at once is likely what's causing the hangs.
- Each upload request also cleans up old temporary upload files. With that many requests running at once, they all try to erase the same files - the first one wins, and the others report "No such file or directory". The CMS was treating that as an error, but nothing is actually wrong: the file was already removed. That's the "Unable to remove file" message your client is seeing.
Here's a patch you can apply to the 3.84 site now. Both changes will also be in the next release.
In cmsb/lib/upload_storage_strategy.php (around line 123), find:
if (!@unlink($filepath)) {
$error = "Unable to remove file '" .htmlencode($filepath). "'\n\n";
$error .= "Please ask your server administrator to check permissions on that file and directory.\n\n";
$error .= "The PHP error message was: " .errorlog_lastError(). "\n";
throw new RuntimeException($error);
}
And replace it with:
if (!@unlink($filepath)) {
clearstatcache(true, $filepath);
if (is_file($filepath)) {
\Itools\Cmsb\CMS::log("Unable to remove upload file '$filepath': " . errorlog_lastError());
}
}
Then in cmsb/lib/menus/default/edit_functions.js (around line 192), find 'multi' : true, and add this line below it:
'simUploadLimit': 10,
That uploads 10 files at a time - the rest queue up in the browser and go automatically, so your client can still select all 100 at once. It should take care of the hangs as well. After updating the .js file, have your client do a hard refresh (Ctrl+F5) so the browser picks up the new version.
Give that a try and let me know if that fixes it for your client. Thanks!
interactivetools.com