Plugin Directory

Changeset 3461494


Ignore:
Timestamp:
02/14/2026 08:09:29 PM (6 weeks ago)
Author:
aamato
Message:

Release 1.1.4 — Cron processes entire queue per run, immediate spawn after scan

Location:
spamanvil
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • spamanvil/tags/1.1.4/admin/class-spamanvil-admin.php

    r3461389 r3461494  
    432432        }
    433433
     434        // Trigger immediate cron run so the queue starts processing without waiting.
     435        if ( $enqueued > 0 ) {
     436            spawn_cron();
     437        }
     438
    434439        wp_send_json_success( array(
    435440            'enqueued'       => $enqueued,
  • spamanvil/tags/1.1.4/includes/class-spamanvil-queue.php

    r3461359 r3461494  
    6767        set_transient( $lock_key, true, 300 ); // 5-minute lock.
    6868
    69         $processed = 0;
     69        // Default time limit for cron: 50 seconds (safe for most hosts).
     70        if ( 0 === $time_limit && ! $force ) {
     71            $time_limit = 50;
     72        }
     73
     74        $processed  = 0;
     75        $start_time = microtime( true );
     76
    7077        try {
    7178            $batch_size = (int) get_option( 'spamanvil_batch_size', 5 );
    72             $items      = $this->claim_items( $batch_size, $force );
    73             $start_time = microtime( true );
    74 
    75             foreach ( $items as $item ) {
    76                 $this->process_single( $item );
    77                 $processed++;
    78 
    79                 // Time guard: stop if approaching limit.
    80                 if ( $time_limit > 0 ) {
    81                     $elapsed = microtime( true ) - $start_time;
    82                     if ( $elapsed >= $time_limit ) {
    83                         // Release unclaimed items back to queue.
    84                         $remaining_ids = array_slice( wp_list_pluck( $items, 'id' ), $processed );
    85                         if ( ! empty( $remaining_ids ) ) {
    86                             $this->release_items( $remaining_ids );
     79
     80            // Loop through batches until queue is empty or time runs out.
     81            do {
     82                $items = $this->claim_items( $batch_size, $force );
     83
     84                if ( empty( $items ) ) {
     85                    break;
     86                }
     87
     88                foreach ( $items as $item ) {
     89                    $this->process_single( $item );
     90                    $processed++;
     91
     92                    // Time guard: stop if approaching limit.
     93                    if ( $time_limit > 0 ) {
     94                        $elapsed = microtime( true ) - $start_time;
     95                        if ( $elapsed >= $time_limit ) {
     96                            // Release unclaimed items back to queue.
     97                            $current_index = array_search( $item, $items, true );
     98                            $remaining     = array_slice( $items, $current_index + 1 );
     99                            $remaining_ids = wp_list_pluck( $remaining, 'id' );
     100                            if ( ! empty( $remaining_ids ) ) {
     101                                $this->release_items( $remaining_ids );
     102                            }
     103                            return $processed;
    87104                        }
    88                         break;
    89105                    }
    90106                }
    91             }
     107
     108                // After force-processing one batch, stop looping (AJAX handles its own loop).
     109                if ( $force ) {
     110                    break;
     111                }
     112
     113            } while ( true );
    92114        } finally {
    93115            delete_transient( $lock_key );
  • spamanvil/tags/1.1.4/readme.txt

    r3461481 r3461494  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.1.3
     8Stable tag: 1.1.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    211211== Changelog ==
    212212
     213= 1.1.4 =
     214* Fix: Cron now processes the entire queue per run (up to 50 seconds) instead of only 5 items — large backlogs clear in minutes, not hours
     215* Fix: Queue processing starts immediately after "Scan Pending Comments" (spawns cron) instead of waiting up to 5 minutes
     216
    213217= 1.1.3 =
    214218* Fix: "Process Queue Now" button is now enabled immediately after "Scan Pending Comments" enqueues items (no page reload needed)
  • spamanvil/tags/1.1.4/spamanvil.php

    r3461481 r3461494  
    44 * Plugin URI:        https://software.amato.com.br/spamanvil-antispam-plugin-for-wordpress/
    55 * Description:       Blocks comment spam using AI/LLM services with support for multiple providers, async processing, and intelligent heuristics.
    6  * Version:           1.1.3
     6 * Version:           1.1.4
    77 * Requires at least: 5.8
    88 * Requires PHP:      7.4
     
    1919}
    2020
    21 define( 'SPAMANVIL_VERSION', '1.1.3' );
     21define( 'SPAMANVIL_VERSION', '1.1.4' );
    2222define( 'SPAMANVIL_DB_VERSION', '1.0.0' );
    2323define( 'SPAMANVIL_PLUGIN_FILE', __FILE__ );
  • spamanvil/trunk/admin/class-spamanvil-admin.php

    r3461389 r3461494  
    432432        }
    433433
     434        // Trigger immediate cron run so the queue starts processing without waiting.
     435        if ( $enqueued > 0 ) {
     436            spawn_cron();
     437        }
     438
    434439        wp_send_json_success( array(
    435440            'enqueued'       => $enqueued,
  • spamanvil/trunk/includes/class-spamanvil-queue.php

    r3461359 r3461494  
    6767        set_transient( $lock_key, true, 300 ); // 5-minute lock.
    6868
    69         $processed = 0;
     69        // Default time limit for cron: 50 seconds (safe for most hosts).
     70        if ( 0 === $time_limit && ! $force ) {
     71            $time_limit = 50;
     72        }
     73
     74        $processed  = 0;
     75        $start_time = microtime( true );
     76
    7077        try {
    7178            $batch_size = (int) get_option( 'spamanvil_batch_size', 5 );
    72             $items      = $this->claim_items( $batch_size, $force );
    73             $start_time = microtime( true );
    74 
    75             foreach ( $items as $item ) {
    76                 $this->process_single( $item );
    77                 $processed++;
    78 
    79                 // Time guard: stop if approaching limit.
    80                 if ( $time_limit > 0 ) {
    81                     $elapsed = microtime( true ) - $start_time;
    82                     if ( $elapsed >= $time_limit ) {
    83                         // Release unclaimed items back to queue.
    84                         $remaining_ids = array_slice( wp_list_pluck( $items, 'id' ), $processed );
    85                         if ( ! empty( $remaining_ids ) ) {
    86                             $this->release_items( $remaining_ids );
     79
     80            // Loop through batches until queue is empty or time runs out.
     81            do {
     82                $items = $this->claim_items( $batch_size, $force );
     83
     84                if ( empty( $items ) ) {
     85                    break;
     86                }
     87
     88                foreach ( $items as $item ) {
     89                    $this->process_single( $item );
     90                    $processed++;
     91
     92                    // Time guard: stop if approaching limit.
     93                    if ( $time_limit > 0 ) {
     94                        $elapsed = microtime( true ) - $start_time;
     95                        if ( $elapsed >= $time_limit ) {
     96                            // Release unclaimed items back to queue.
     97                            $current_index = array_search( $item, $items, true );
     98                            $remaining     = array_slice( $items, $current_index + 1 );
     99                            $remaining_ids = wp_list_pluck( $remaining, 'id' );
     100                            if ( ! empty( $remaining_ids ) ) {
     101                                $this->release_items( $remaining_ids );
     102                            }
     103                            return $processed;
    87104                        }
    88                         break;
    89105                    }
    90106                }
    91             }
     107
     108                // After force-processing one batch, stop looping (AJAX handles its own loop).
     109                if ( $force ) {
     110                    break;
     111                }
     112
     113            } while ( true );
    92114        } finally {
    93115            delete_transient( $lock_key );
  • spamanvil/trunk/readme.txt

    r3461481 r3461494  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.1.3
     8Stable tag: 1.1.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    211211== Changelog ==
    212212
     213= 1.1.4 =
     214* Fix: Cron now processes the entire queue per run (up to 50 seconds) instead of only 5 items — large backlogs clear in minutes, not hours
     215* Fix: Queue processing starts immediately after "Scan Pending Comments" (spawns cron) instead of waiting up to 5 minutes
     216
    213217= 1.1.3 =
    214218* Fix: "Process Queue Now" button is now enabled immediately after "Scan Pending Comments" enqueues items (no page reload needed)
  • spamanvil/trunk/spamanvil.php

    r3461481 r3461494  
    44 * Plugin URI:        https://software.amato.com.br/spamanvil-antispam-plugin-for-wordpress/
    55 * Description:       Blocks comment spam using AI/LLM services with support for multiple providers, async processing, and intelligent heuristics.
    6  * Version:           1.1.3
     6 * Version:           1.1.4
    77 * Requires at least: 5.8
    88 * Requires PHP:      7.4
     
    1919}
    2020
    21 define( 'SPAMANVIL_VERSION', '1.1.3' );
     21define( 'SPAMANVIL_VERSION', '1.1.4' );
    2222define( 'SPAMANVIL_DB_VERSION', '1.0.0' );
    2323define( 'SPAMANVIL_PLUGIN_FILE', __FILE__ );
Note: See TracChangeset for help on using the changeset viewer.