ee92c36e by Chris Boden

Fixed loop on invoice fix

1 parent 3624166b
...@@ -21,7 +21,12 @@ $begin_date = strtotime('March 1'); ...@@ -21,7 +21,12 @@ $begin_date = strtotime('March 1');
21 date_default_timezone_set($original_timezone); 21 date_default_timezone_set($original_timezone);
22 22
23 if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') { 23 if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') {
24 $users = $wpdb->get_results("SELECT ID FROM {$wpdb->users} LIMIT 0,1000"); 24 $count_result = mysql_query("SELECT COUNT(*) FROM `{$wpdb->users}`", $wpdb->dbh);
25 list($num) = mysql_fetch_row($count_result);
26 $max = 1000;
27
28 for ($ui = 0; $ui < $num; $ui += $max) {
29 $users = $wpdb->get_results("SELECT ID FROM `{$wpdb->users}` LIMIT {$ui}, {$max}");
25 foreach ($users as $user) { 30 foreach ($users as $user) {
26 $invoices = get_user_meta($user->ID, 'invoices', TRUE); 31 $invoices = get_user_meta($user->ID, 'invoices', TRUE);
27 foreach ($invoices as $invoice_id) { 32 foreach ($invoices as $invoice_id) {
...@@ -59,6 +64,8 @@ if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') { ...@@ -59,6 +64,8 @@ if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') {
59 update_post_meta($invoice_id, 'trans_amount', $trans_amount); 64 update_post_meta($invoice_id, 'trans_amount', $trans_amount);
60 } 65 }
61 } 66 }
67 unset($users, $invoices);
68 }
62 } 69 }
63 70
64 ?> 71 ?>
......