Making WordPress.org

Changeset 2668


Ignore:
Timestamp:
03/02/2016 03:30:35 PM (9 years ago)
Author:
kovshenin
Message:

WordCamp Budgets: Provide globally unique check numbers for JPM exports.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/payment-requests-dashboard.php

    r2666 r2668  
    571571        $count = 0;
    572572
     573        if ( false !== get_site_transient( '_wcb_jpm_checks_counter_lock' ) ) {
     574            wp_die( 'JPM Checks Export is locked. Please try again later or contact support.' );
     575        }
     576
     577        // Avoid at least *some* race conditions.
     578        set_site_transient( '_wcb_jpm_checks_counter_lock', 1, 30 );
     579        $start = absint( get_site_option( '_wcb_jpm_checks_counter', 0 ) );
     580
    573581        foreach ( $args['request_indexes'] as $index ) {
    574582            switch_to_blog( $index->blog_id );
     
    608616                number_format( $amount, 2, '.', '' ),
    609617                $options['account_number'],
    610                 $count, // must be globally unique?
     618                $start + $count, // must be globally unique?
    611619                $options['contact_email'],
    612620                $options['contact_phone'],
     
    618626                substr( $payable_to, 0, 35 ),
    619627                '',
    620                 $count, // vendor number. should be unique?
     628                sprintf( '%d-%d', $index->blog_id, $index->post_id ),
    621629            ), ',', '|' );
    622630
     
    651659        // File Trailer
    652660        fputcsv( $report, array( 'FILTRL', $count * 6 + 2 ), ',', '|' );
     661
     662        // Update counter and unlock
     663        $start = absint( get_site_option( '_wcb_jpm_checks_counter', 0 ) );
     664        update_site_option( '_wcb_jpm_checks_counter', $start + $count );
     665        delete_site_transient( '_wcb_jpm_checks_counter_lock' );
    653666
    654667        fclose( $report );
Note: See TracChangeset for help on using the changeset viewer.