• Resolved Darko G.

    (@darkog)


    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 need a+ flag because you aren’t reading the file but only writing to it. Having the a+ flag only makes your plugin incompatible with S3 based file systems.

    Some resources:

    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 replacing a+

    Looking forward to hearing from you.

    Best Regards,
    Darko

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Md Monir Hossain

    (@monircoderex)

    Hi @darkog,

    Thank you for bringing this to our attention.

    We will check and get back to you with an update soon.

    Regards,

    Thread Starter Darko G.

    (@darkog)

    Hey @monircoderex,

    Thanks for your quick reply.

    I look forward hearing more on this.

    Best Regards,
    Darko

    Plugin Support Md Monir Hossain

    (@monircoderex)

    Dear @darkog,
    Thank you for bringing this to our attention and providing the necessary details. Your input is incredibly valuable in improving our plugin’s functionality.


    I’m thrilled to inform you that we’ve taken swift action on your suggestion. In our latest release (7.3.21 as of 2023-12-14), we’ve addressed the file open mode concern exactly as you recommended. Now, the file open mode has been adjusted, and additionally, we’ve introduced a filter hook allowing users to customize the file open mode according to their requirements.


    We greatly appreciate your contribution and hope this enhancement aligns better with systems like S3-Uploads, ensuring smoother functionality.


    Best Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Incompatible with S3-Uploads’ is closed to new replies.