Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member Export outputs duplicates when using pmpro_set_max_user_per_export_loop filter #3291

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions adminpages/memberslist-csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
* @since 1.8.7
*/
//set the number of users we'll load to try and protect ourselves from OOM errors
$max_users_per_loop = apply_filters('pmpro_set_max_user_per_export_loop', 2000);
$max_users_per_loop = intval( apply_filters( 'pmpro_set_max_user_per_export_loop', 2000 ) );

//If the filter returns odd value, reset to default.
if ( $max_users_per_loop < 1 ) {
$max_users_per_loop = 2000;
}
global $wpdb;

//get users (search input field)
Expand Down Expand Up @@ -309,16 +313,11 @@

$start = current_time('timestamp');

// Get the last record to output, will depend on which iteration we're on.
if ( $ic != $iterations ) {
$i_end = ($i_start + ( $max_users_per_loop - 1));
} else {
// Final iteration, so last UID is the last record in the users array
$i_end = ($users_found - 1);
}
$spl = array_slice($theusers, $i_start, $i_end + 1);
$i_end = min( $i_start + $max_users_per_loop - 1, $users_found - 1 );

$spl = array_slice( $theusers, $i_start, $i_end - $i_start + 1 );
//increment starting position
$i_start += $max_users_per_loop;
$i_start = $i_end + 1;

//escape the % for LIKE comparison with $wpdb
if(!empty($search))
Expand Down