@@ -740,33 +740,35 @@ function ReduceMailQueue($number = false, $override_limit = false, $force_send =
740740 $ smcFunc ['db_free_result ' ]($ request );
741741
742742 // Random emails from the queue..
743- $ request = $ smcFunc ['db_query ' ]('' , '
744- SELECT id_mail, recipient, body, subject, headers, send_html, time_sent, private, priority
745- FROM {db_prefix}mail_queue
746- WHERE id_mail NOT IN ({array_int:ids})
747- ORDER BY RAND()
748- LIMIT {int:limit} ' ,
749- array (
750- 'ids ' => $ ids ,
751- 'limit ' => ceil ($ number * 0.3 ),
752- )
753- );
754- while ($ row = $ smcFunc ['db_fetch_assoc ' ]($ request ))
755- {
756- // We want to delete these from the database ASAP, so just get the data and go.
757- $ ids [] = $ row ['id_mail ' ];
758- $ emails [] = array (
759- 'to ' => $ row ['recipient ' ],
760- 'body ' => $ row ['body ' ],
761- 'subject ' => $ row ['subject ' ],
762- 'headers ' => $ row ['headers ' ],
763- 'send_html ' => $ row ['send_html ' ],
764- 'time_sent ' => $ row ['time_sent ' ],
765- 'private ' => $ row ['private ' ],
766- 'priority ' => $ row ['priority ' ],
743+ if (!empty ($ ids )) {
744+ $ request = $ smcFunc ['db_query ' ]('' , '
745+ SELECT id_mail, recipient, body, subject, headers, send_html, time_sent, private, priority
746+ FROM {db_prefix}mail_queue
747+ WHERE id_mail NOT IN ({array_int:ids})
748+ ORDER BY RAND()
749+ LIMIT {int:limit} ' ,
750+ array (
751+ 'ids ' => $ ids ,
752+ 'limit ' => ceil ($ number * 0.3 ),
753+ )
767754 );
755+ while ($ row = $ smcFunc ['db_fetch_assoc ' ]($ request ))
756+ {
757+ // We want to delete these from the database ASAP, so just get the data and go.
758+ $ ids [] = $ row ['id_mail ' ];
759+ $ emails [] = array (
760+ 'to ' => $ row ['recipient ' ],
761+ 'body ' => $ row ['body ' ],
762+ 'subject ' => $ row ['subject ' ],
763+ 'headers ' => $ row ['headers ' ],
764+ 'send_html ' => $ row ['send_html ' ],
765+ 'time_sent ' => $ row ['time_sent ' ],
766+ 'private ' => $ row ['private ' ],
767+ 'priority ' => $ row ['priority ' ],
768+ );
769+ }
770+ $ smcFunc ['db_free_result ' ]($ request );
768771 }
769- $ smcFunc ['db_free_result ' ]($ request );
770772
771773 // Delete, delete, delete!!!
772774 if (!empty ($ ids ))
0 commit comments