Skip to content

Commit

Permalink
CampTix: Format SQL queries for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
iandunn committed Sep 25, 2023
1 parent e3e0cfc commit 0f8c745
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions public_html/wp-content/plugins/camptix/camptix.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,17 @@ function send_emails_batch() {
$this->log( 'Executing e-mail job.', $email->ID, null, 'notify' );
$max = apply_filters( 'camptix_notify_recipients_batch_count', 200 ); // plugins can change this.

$recipients_data = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS meta_id, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.post_id = %d AND $wpdb->postmeta.meta_key = %s LIMIT %d;", $email->ID, 'tix_email_recipient_id', $max ) );
$recipients_data = $wpdb->get_results( $wpdb->prepare( "
SELECT SQL_CALC_FOUND_ROWS meta_id, meta_value
FROM $wpdb->postmeta
WHERE
$wpdb->postmeta.post_id = %d AND
$wpdb->postmeta.meta_key = %s
LIMIT %d;",
$email->ID,
'tix_email_recipient_id',
$max
) );
$total = $wpdb->get_var( "SELECT FOUND_ROWS();" );
$processed = 0;

Expand Down Expand Up @@ -270,7 +280,15 @@ function send_emails_batch() {

foreach ( $attendees as $attendee_id ) {
$attendee_email = get_post_meta( $attendee_id, 'tix_email', true );
$count = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_id = %d LIMIT 1;", $email->ID, $recipients[$attendee_id] ) );
$count = $wpdb->query( $wpdb->prepare( "
DELETE FROM $wpdb->postmeta
WHERE
post_id = %d AND
meta_id = %d
LIMIT 1;",
$email->ID,
$recipients[$attendee_id]
) );

if ( $count > 0 ) {

Expand Down

0 comments on commit 0f8c745

Please sign in to comment.