Plugin Directory

Changeset 3106344


Ignore:
Timestamp:
06/23/2024 11:48:55 PM (21 months ago)
Author:
tmmtechnology
Message:

Plugin update: Fix object cache bug

Location:
cache-warmer
Files:
4 edited
39 copied

Legend:

Unmodified
Added
Removed
  • cache-warmer/tags/1.3.0/cache-warmer.php

    r3106098 r3106344  
    33 * Plugin Name: Cache Warmer
    44 * Description: Visits website pages to warm (create) the cache if you have any caching solutions configured.
    5  * Version:     1.2.5
     5 * Version:     1.3.0
    66 * Text Domain: cache-warmer
    77 * Author:      TMM Technology
  • cache-warmer/tags/1.3.0/readme.txt

    r3106098 r3106344  
    33Tags: cache, warming, cloudflare, redis, object cache
    44Tested up to: 6.5.4
    5 Stable tag: 1.2.5
     5Stable tag: 1.3.0
    66Requires PHP: 7.4
    77License: GPLv3
     
    5050== Changelog ==
    5151
     52= 1.3.0 2024-06-24 =
     53
     54#### Enhancements
     55
     56* Speed up warmings (optimization).
     57
     58#### Bugfixes
     59
     60* Fix stuck object cache bug.
     61
    5262= 1.2.5 2024-06-23 =
    5363
  • cache-warmer/tags/1.3.0/src/class-object-cache.php

    r3106098 r3106344  
    2222     */
    2323    public static function use_object_cache() {
    24         return '1' === Cache_Warmer::$options->get( 'setting-use-object-cache' );
     24        return wp_using_ext_object_cache() && '1' === Cache_Warmer::$options->get( 'setting-use-object-cache' );
    2525    }
    2626}
  • cache-warmer/tags/1.3.0/src/class-warm-up.php

    r3081567 r3106344  
    650650
    651651    /**
    652      * Returns log content.
    653      *
    654      * @param string $warmed_at        File name to get the log content for.
    655      * @param int    $for_last_minutes For how many minutes to get the fetches for.
     652     * Returns the count of how many fetches were done for the warmup, for the last minute.
     653     *
     654     * @param array $visited_links The array of visited links.
    656655     *
    657656     * @return int Count.
    658657     */
    659     public static function how_many_fetches_were_done_for_the_warmup( $warmed_at, $for_last_minutes = 1 ) {
    660         global $wpdb;
    661 
    662         $logs_table = DB::get_tables_prefix() . 'warm_ups_logs';
    663         $list_table = DB::get_tables_prefix() . 'warm_ups_list';
    664 
    665         $threshold = wp_date(
    666             'Y-m-d H:i:s',
    667             time() - MINUTE_IN_SECONDS * $for_last_minutes
     658    public static function how_many_fetches_were_done_for_the_warmup( array &$visited_links ) {
     659        $current_time = time();
     660
     661        // Remove timestamps older than 60 seconds.
     662        $visited_links = array_filter(
     663            $visited_links,
     664            function ( $timestamp ) use ( $current_time ) {
     665                return ( $current_time - $timestamp ) <= 60;
     666            }
    668667        );
    669668
    670         $results = $wpdb->get_results(
    671             $wpdb->prepare(
    672                 "
    673                 SELECT COUNT(*)
    674                 FROM $logs_table
    675                 INNER JOIN $list_table ON $logs_table.list_id=$list_table.id
    676                 WHERE $list_table.warmed_at = %s AND $logs_table.log_date >= %s
    677                 ",
    678                 $warmed_at,
    679                 $threshold
    680             ),
    681             ARRAY_N
    682         );
    683 
    684         return (int) $results[0][0];
     669        // Add the current timestamp.
     670        $visited_links[] = $current_time;
     671
     672        // Return the count of the visited links.
     673        return count( $visited_links );
    685674    }
    686675
     
    709698        $meta = $data['meta'];
    710699
    711         $warmup_start_date = $meta['start_date'];
    712 
    713700        if ( ! array_key_exists( 'speed_limit', $meta ) ) {
    714701            $meta['speed_limit'] = 1000;
     
    716703
    717704        $speed_limit = &$meta['speed_limit'];
     705
     706        if ( ! array_key_exists( 'visited_links', $meta ) ) {
     707            $meta['visited_links'] = [];
     708        }
     709
     710        $visited_links = &$meta['visited_links'];
    718711
    719712        self::$failed_links_option_key = ! $warm_up_for_unscheduled ?
     
    741734            ++ $i <= self::BATCH_SIZE && // Or until batch size is hit.
    742735            // Or until the current speed is too fast and over the limit.
    743             ( $how_many_fetches_were_done = self::how_many_fetches_were_done_for_the_warmup( $warmup_start_date ) ) < $speed_limit // @codingStandardsIgnoreLine
     736            ( $how_many_fetches_were_done = self::how_many_fetches_were_done_for_the_warmup( $visited_links ) ) < $speed_limit // @codingStandardsIgnoreLine
    744737        ) {
    745738            $first_link_data = Tree::get_the_first_leaf_data( $tree );
  • cache-warmer/trunk/cache-warmer.php

    r3106098 r3106344  
    33 * Plugin Name: Cache Warmer
    44 * Description: Visits website pages to warm (create) the cache if you have any caching solutions configured.
    5  * Version:     1.2.5
     5 * Version:     1.3.0
    66 * Text Domain: cache-warmer
    77 * Author:      TMM Technology
  • cache-warmer/trunk/readme.txt

    r3106098 r3106344  
    33Tags: cache, warming, cloudflare, redis, object cache
    44Tested up to: 6.5.4
    5 Stable tag: 1.2.5
     5Stable tag: 1.3.0
    66Requires PHP: 7.4
    77License: GPLv3
     
    5050== Changelog ==
    5151
     52= 1.3.0 2024-06-24 =
     53
     54#### Enhancements
     55
     56* Speed up warmings (optimization).
     57
     58#### Bugfixes
     59
     60* Fix stuck object cache bug.
     61
    5262= 1.2.5 2024-06-23 =
    5363
  • cache-warmer/trunk/src/class-object-cache.php

    r3106098 r3106344  
    2222     */
    2323    public static function use_object_cache() {
    24         return '1' === Cache_Warmer::$options->get( 'setting-use-object-cache' );
     24        return wp_using_ext_object_cache() && '1' === Cache_Warmer::$options->get( 'setting-use-object-cache' );
    2525    }
    2626}
  • cache-warmer/trunk/src/class-warm-up.php

    r3081567 r3106344  
    650650
    651651    /**
    652      * Returns log content.
    653      *
    654      * @param string $warmed_at        File name to get the log content for.
    655      * @param int    $for_last_minutes For how many minutes to get the fetches for.
     652     * Returns the count of how many fetches were done for the warmup, for the last minute.
     653     *
     654     * @param array $visited_links The array of visited links.
    656655     *
    657656     * @return int Count.
    658657     */
    659     public static function how_many_fetches_were_done_for_the_warmup( $warmed_at, $for_last_minutes = 1 ) {
    660         global $wpdb;
    661 
    662         $logs_table = DB::get_tables_prefix() . 'warm_ups_logs';
    663         $list_table = DB::get_tables_prefix() . 'warm_ups_list';
    664 
    665         $threshold = wp_date(
    666             'Y-m-d H:i:s',
    667             time() - MINUTE_IN_SECONDS * $for_last_minutes
     658    public static function how_many_fetches_were_done_for_the_warmup( array &$visited_links ) {
     659        $current_time = time();
     660
     661        // Remove timestamps older than 60 seconds.
     662        $visited_links = array_filter(
     663            $visited_links,
     664            function ( $timestamp ) use ( $current_time ) {
     665                return ( $current_time - $timestamp ) <= 60;
     666            }
    668667        );
    669668
    670         $results = $wpdb->get_results(
    671             $wpdb->prepare(
    672                 "
    673                 SELECT COUNT(*)
    674                 FROM $logs_table
    675                 INNER JOIN $list_table ON $logs_table.list_id=$list_table.id
    676                 WHERE $list_table.warmed_at = %s AND $logs_table.log_date >= %s
    677                 ",
    678                 $warmed_at,
    679                 $threshold
    680             ),
    681             ARRAY_N
    682         );
    683 
    684         return (int) $results[0][0];
     669        // Add the current timestamp.
     670        $visited_links[] = $current_time;
     671
     672        // Return the count of the visited links.
     673        return count( $visited_links );
    685674    }
    686675
     
    709698        $meta = $data['meta'];
    710699
    711         $warmup_start_date = $meta['start_date'];
    712 
    713700        if ( ! array_key_exists( 'speed_limit', $meta ) ) {
    714701            $meta['speed_limit'] = 1000;
     
    716703
    717704        $speed_limit = &$meta['speed_limit'];
     705
     706        if ( ! array_key_exists( 'visited_links', $meta ) ) {
     707            $meta['visited_links'] = [];
     708        }
     709
     710        $visited_links = &$meta['visited_links'];
    718711
    719712        self::$failed_links_option_key = ! $warm_up_for_unscheduled ?
     
    741734            ++ $i <= self::BATCH_SIZE && // Or until batch size is hit.
    742735            // Or until the current speed is too fast and over the limit.
    743             ( $how_many_fetches_were_done = self::how_many_fetches_were_done_for_the_warmup( $warmup_start_date ) ) < $speed_limit // @codingStandardsIgnoreLine
     736            ( $how_many_fetches_were_done = self::how_many_fetches_were_done_for_the_warmup( $visited_links ) ) < $speed_limit // @codingStandardsIgnoreLine
    744737        ) {
    745738            $first_link_data = Tree::get_the_first_leaf_data( $tree );
Note: See TracChangeset for help on using the changeset viewer.