silverstripe / silverstripe-staticpublishqueue

This module allows you to build static HTML caches of every page (for increased security and performance)
BSD 3-Clause "New" or "Revised" License
46 stars 57 forks source link

Bugfix: Use copy() and unlink() instead of rename() #164

Closed chrispenny closed 1 year ago

chrispenny commented 1 year ago

When attempting to process GenerateStaticCacheJob:

ERROR [Warning]: rename(/tmp/silverstripe-cache-php8.1.14-var-www-mysite-www/vagrant/filesystempublisher_lhg6Yg,/var/www/mysite/www/public/cache/copyright-and-legal-statement.html): Operation not permitted
IN GET dev/tasks/ProcessJobQueueTask
Line 193 in /var/www/mysite/www/vendor/silverstripe/staticpublishqueue/src/Publisher/FilesystemPublisher.php

My directories all have the appropriate permissions.

Found this thread, which talks about similar issues, and it sounded like copy() and unlink() had more success: https://ubuntuforums.org/showthread.php?t=1272466

I confirmed this to be true for us. I no longer get any Warning when performing these two actions separately.

Related resources

blueo commented 1 year ago

just to add some context - it appears that in some scenarios php's rename will not work across filesystems - using a copy/unlink gets around this limitation so its probably a safer mechanism than rename.