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)

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:

  1. 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.
  2. 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!

Dave Edis - Senior Developer
interactivetools.com