Incompatible with S3-Uploads
-
Hey,
We are using S3-Uploads addon to offload the uploads directory to S3.
I see that your plugin uses
a+
flag when opening the xml/csv file for writing. This is not supported by AWS S3 and the plugin throws errors when trying to save the file.If i change the flag to only
a
– it works. And you really don’t needa+
flag because you aren’t reading the file but only writing to it. Having thea+
flag only makes your plugin incompatible with S3 based file systems.Some resources:
- What is the difference between a and a+ (C++ related but same with PHP)
- S3-Uploads github issue related to the problem
This is where the
a+
flag is located in your code:function wpfm_generate_csv_feed( $feed, $file, $separator, $batch ) { $list = $feed; $list = is_array( $list ) ? $list : array(); if ( $batch == 1 ) { if ( file_exists( $file ) ) { unlink( $file ); } } else { array_shift( $list ); } $file = fopen( $file, "a+" ); foreach ( $list as $line ) { $lines = array(); foreach ( $line as $l ) { $lines[] = wpfm_replace_special_char( $l ); } if ( $separator === 'semi_colon' ) { fputcsv( $file, $lines, ';' ); } elseif ( $separator === 'pipe' ) { fputcsv( $file, $lines, '|' ); } else { fputcsv( $file, $lines ); } } fclose( $file ); return 'true'; }
If you can provide a filter so we can alter that flag like:
$file = fopen( $file, apply_filters('your_plugin_prefix_file_open_mode', 'a+' );
or just set that
a
flag by default replacinga+
…Looking forward to hearing from you.
Best Regards,
Darko
- The topic ‘Incompatible with S3-Uploads’ is closed to new replies.