cedaro / satispress

Expose installed WordPress plugins and themes as Composer packages.
500 stars 48 forks source link

Operation not permitted warning on local dev env (mounted filesystem) #190

Open andronocean opened 1 year ago

andronocean commented 1 year ago

Hi, and first of all thank you so much for creating satispress — this project has been an absolute lifesaver!

This issue is a very low priority, since nothing actually breaks. The warning gets emitted on this rename() call when archiving a new plugin release:

https://github.com/cedaro/satispress/blob/aca49486c7f5e1a35b9c9184392c3ab1297e8efc/src/Storage/Local.php#L134

Here's an example of the warning from debug.log. This seems to appear any time a new release for a watched plugin (here, for example, Gutenberg) is being archived:

PHP Warning:  rename(/tmp/satispress/gutenberg-14.0.2.zip,/srv/www/example.test/current/web/app/uploads/satispress-lnWtRfJc1aeA/packages/gutenberg/gutenberg-14.0.2.zip): Operation not permitted in /srv/www/example.test/current/web/app/plugins/satispress/src/Storage/Local.php on line 134

The rename/move does work, however, since the zip in /tmp/satispress is deleted and reappears at the /srv/www... location. Permissions look fine. So everything functions — but warnings appear in WP debug.log occasionally.

I've only seen this warning on my local dev environment, never in production. For local dev I'm running Trellis on a Mac, with Vagrant on Virtualbox as the VM provider, so mounted filesystems are involved between the Linux VM and my Mac. Specifically /tmp/ and /srv/www/example.test/current/ are on different filesystems. This is almost certainly the root cause of the warning.

Hence I'm pretty sure this is related to the cross-filesystem rename() behavior described in this comment: https://www.php.net/manual/en/function.rename.php#117590.

Again, low-priority, and I can submit a fix PR if you like. Mostly I just wanted to document this in case anyone else comes across the same situation, or something similar.

bradyvercher commented 1 year ago

Hi @andronocean, I apologize for the delay, but I'm glad to hear you've found SatisPress useful!

There haven't been any other reports, but I appreciate you opening this just in case. Would the fix involve using copy/unlink instead of rename? If you'd like to submit a PR, I can get that merged to get rid of that debug pollution.