• Resolved Calin Don

    (@calin)


    The plugin has some issues when using PHP Stream Wrappers backed by S3 or Google Cloud Storage, failing with “gs://bucket-name/wp-content/uploads/2017/12 is not writable”.

    The issue reside in the fact that object storage are key/values stores with no notion of directories. A directory in this context is rather a convention, in general a key ending with ‘/’. PHP’s dirname returns the path without the trailing ‘/’.

    From what I can tell the fix is rather trivial, in lib/class-wp-smush.php, $dir_name in do_smushit function must be wrapped in a trailingslashit. This does not affect Linux/Windows/MacOS because dir and dir/ are equivalent.

    Here’s the patch as well:

    
    --- a/wp-smushit/lib/class-wp-smush.php	2017-10-03 20:04:20.000000000 +0300
    +++ b/wp-smushit/lib/class-wp-smush.php	2017-12-07 16:49:49.000000000 +0200
    @@ -191,7 +191,7 @@
     		 */
     		function do_smushit( $file_path = '' ) {
     			$errors   = new WP_Error();
    -			$dir_name = dirname( $file_path );
    +			$dir_name = trailingslashit( dirname( $file_path ) );
    
     			//Check if file exists and the directory is writable
     			if ( empty( $file_path ) ) {
    
    • This topic was modified 6 years, 4 months ago by Calin Don. Reason: styling
Viewing 1 replies (of 1 total)
  • @calin, Thanks for posting. I’ll try to replicate and see if the patch works.

    If it all works good, I’ll make sure to include the patch in upcoming release.

    Thanks, Umesh

Viewing 1 replies (of 1 total)
  • The topic ‘Problems with object storages (S3, Google Cloud) as PHP stream wrappers’ is closed to new replies.