Plugin Directory

Changeset 3344786


Ignore:
Timestamp:
08/14/2025 04:33:37 PM (7 months ago)
Author:
malakontask
Message:

Update to version 2.8.1 - Bug fixes and improvements for WooCommerce brand taxonomy transfer

Location:
transfer-brands-for-woocommerce
Files:
8 added
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • transfer-brands-for-woocommerce/tags/2.8.1/CHANGELOG.md

    r3341810 r3344786  
    55The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
    66and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     7
     8## [2.8.1] - 2025-08-09
     9
     10### Changed
     11- Buffered debug logging writes to a single shutdown update per request
     12- Limited `tbfw_brands_debug_log` to last 1000 entries to prevent unbounded growth
     13- Ensured heavy options (`tbfw_backup`, `tbfw_term_mappings`, `tbfw_deleted_brands_backup`, `tbfw_brands_processed_ids`, `tbfw_backup_cleanup_log`, `tbfw_brands_debug_log`) are non-autoloaded
     14- Removed global `wp_cache_flush()` usage from admin UI and counts refresh; replaced with targeted cache deletion
     15- Escaped debug output in Debug page to avoid XSS in admin
     16
     17### Fixed
     18- Reduced slow queries on multisite and large stores caused by frequent option reads/writes
    719
    820## [2.8.0] - 2025-08-08
  • transfer-brands-for-woocommerce/tags/2.8.1/includes/class-admin.php

    r3294781 r3344786  
    524524                                <button class="button" onclick="jQuery('#product-<?php echo esc_attr($product['id']); ?>').toggle();"><?php esc_html_e('Show Details', 'transfer-brands-for-woocommerce'); ?></button>
    525525                                <div id="product-<?php echo esc_attr($product['id']); ?>" style="display: none; margin-top: 10px;">
    526                                     <pre><?php print_r($product['attribute']); ?></pre>
     526                                    <?php $attr_dump = print_r($product['attribute'], true); ?>
     527                                    <pre><?php echo esc_html($attr_dump); ?></pre>
    527528                                </div>
    528529                            </td>
     
    551552                        <button class="button button-small" onclick="jQuery('#log-data-<?php echo esc_attr($index); ?>').toggle();"><?php esc_html_e('Show Data', 'transfer-brands-for-woocommerce'); ?></button>
    552553                        <div id="log-data-<?php echo esc_attr($index); ?>" style="display: none; margin-top: 5px; padding: 5px; background: #fff;">
    553                             <pre><?php print_r($entry['data']); ?></pre>
     554                            <?php $data_dump = print_r($entry['data'], true); ?>
     555                            <pre><?php echo esc_html($data_dump); ?></pre>
    554556                        </div>
    555557                        <?php endif; ?>
     
    587589     */
    588590    public function admin_page() {
    589         // Clear cache to ensure we have fresh data
    590         wp_cache_flush();
     591        // Avoid global cache flush here to prevent heavy performance impact
    591592       
    592593        // Get current tab
  • transfer-brands-for-woocommerce/tags/2.8.1/includes/class-ajax.php

    r3341810 r3344786  
    585585        }
    586586       
    587         // Clear object cache
    588         wp_cache_flush();
    589        
    590587        // Delete transients that might affect the counts
    591588        delete_transient('tbfw_count_comments');
     
    593590        delete_transient('wc_term_counts');
    594591       
    595         // Clear object cache
     592        // Clear WooCommerce-related cache keys where possible without global flush
    596593        if (function_exists('wp_cache_delete')) {
    597594            wp_cache_delete('product-transient-version', 'transient');
  • transfer-brands-for-woocommerce/tags/2.8.1/includes/class-core.php

    r3294781 r3344786  
    9090     */
    9191    private $debug_log = [];
     92    /**
     93     * Tracks whether the debug log has been loaded from the database
     94     * and whether a single write has been scheduled for shutdown.
     95     *
     96     * @since 2.8.1
     97     * @var bool
     98     */
     99    private $has_loaded_debug_log = false;
     100    private $has_scheduled_debug_write = false;
    92101   
    93102    /**
     
    207216            return;
    208217        }
    209        
    210         $this->debug_log = get_option('tbfw_brands_debug_log', []);
    211        
     218        // Load once per request
     219        if (!$this->has_loaded_debug_log) {
     220            $this->debug_log = get_option('tbfw_brands_debug_log', []);
     221            $this->has_loaded_debug_log = true;
     222        }
     223       
    212224        $this->debug_log[] = [
    213225            'time' => current_time('mysql'),
     
    215227            'data' => $data
    216228        ];
    217        
    218         update_option('tbfw_brands_debug_log', $this->debug_log);
     229       
     230        // Schedule a single write at shutdown instead of writing on every call
     231        if (!$this->has_scheduled_debug_write) {
     232            $this->has_scheduled_debug_write = true;
     233            add_action('shutdown', function() {
     234                // Cap the log to the most recent 1000 entries to avoid unbounded growth
     235                $log = $this->debug_log;
     236                if (is_array($log) && count($log) > 1000) {
     237                    $log = array_slice($log, -1000);
     238                }
     239                update_option('tbfw_brands_debug_log', $log);
     240            });
     241        }
    219242    }
    220243   
  • transfer-brands-for-woocommerce/tags/2.8.1/readme.txt

    r3341810 r3344786  
    44Requires at least: 6.0
    55Tested up to: 6.8.2
    6 Stable tag: 2.8.0
     6Stable tag: 2.8.1
    77Requires PHP: 7.4
    88License: GPLv2 or later
  • transfer-brands-for-woocommerce/tags/2.8.1/transfer-brands-for-woocommerce.php

    r3341810 r3344786  
    44 * Plugin URI: https://pluginatlas.com/transfer-brands-for-woocommerce
    55 * Description: Official migration tool for WooCommerce 9.6 Brands. Safely transfer your product brand attributes to the new brand taxonomy with image support, batch processing, and full backup capabilities.
    6  * Version: 2.8.0
     6 * Version: 2.8.1
    77 * Requires at least: 6.0
    88 * Requires PHP: 7.4
     
    3636
    3737// Define plugin constants
    38 define('TBFW_VERSION', '2.8.0');
     38define('TBFW_VERSION', '2.8.1');
    3939define('TBFW_PLUGIN_DIR', plugin_dir_path(__FILE__));
    4040define('TBFW_PLUGIN_URL', plugin_dir_url(__FILE__));
     
    155155        ]);
    156156    }
     157
     158    // Ensure debug-related options exist and are not autoloaded to avoid slow autoload queries
     159    if (false === get_option('tbfw_brands_debug_log', false)) {
     160        add_option('tbfw_brands_debug_log', [], '', 'no');
     161    } else {
     162        // If it exists but might be autoloaded, switch to non-autoloaded
     163        update_option('tbfw_brands_debug_log', get_option('tbfw_brands_debug_log', []), false);
     164    }
     165
     166    // Pre-create heavy options as non-autoloaded to prevent loading on every request
     167    if (false === get_option('tbfw_backup', false)) {
     168        add_option('tbfw_backup', [], '', 'no');
     169    } else {
     170        update_option('tbfw_backup', get_option('tbfw_backup', []), false);
     171    }
     172
     173    if (false === get_option('tbfw_term_mappings', false)) {
     174        add_option('tbfw_term_mappings', [], '', 'no');
     175    } else {
     176        update_option('tbfw_term_mappings', get_option('tbfw_term_mappings', []), false);
     177    }
     178
     179    if (false === get_option('tbfw_deleted_brands_backup', false)) {
     180        add_option('tbfw_deleted_brands_backup', [], '', 'no');
     181    } else {
     182        update_option('tbfw_deleted_brands_backup', get_option('tbfw_deleted_brands_backup', []), false);
     183    }
     184
     185    if (false === get_option('tbfw_brands_processed_ids', false)) {
     186        add_option('tbfw_brands_processed_ids', [], '', 'no');
     187    } else {
     188        update_option('tbfw_brands_processed_ids', get_option('tbfw_brands_processed_ids', []), false);
     189    }
     190
     191    if (false === get_option('tbfw_backup_cleanup_log', false)) {
     192        add_option('tbfw_backup_cleanup_log', [], '', 'no');
     193    } else {
     194        update_option('tbfw_backup_cleanup_log', get_option('tbfw_backup_cleanup_log', []), false);
     195    }
    157196   
    158197    // Flush rewrite rules
  • transfer-brands-for-woocommerce/trunk/CHANGELOG.md

    r3341810 r3344786  
    55The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
    66and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     7
     8## [2.8.1] - 2025-08-09
     9
     10### Changed
     11- Buffered debug logging writes to a single shutdown update per request
     12- Limited `tbfw_brands_debug_log` to last 1000 entries to prevent unbounded growth
     13- Ensured heavy options (`tbfw_backup`, `tbfw_term_mappings`, `tbfw_deleted_brands_backup`, `tbfw_brands_processed_ids`, `tbfw_backup_cleanup_log`, `tbfw_brands_debug_log`) are non-autoloaded
     14- Removed global `wp_cache_flush()` usage from admin UI and counts refresh; replaced with targeted cache deletion
     15- Escaped debug output in Debug page to avoid XSS in admin
     16
     17### Fixed
     18- Reduced slow queries on multisite and large stores caused by frequent option reads/writes
    719
    820## [2.8.0] - 2025-08-08
  • transfer-brands-for-woocommerce/trunk/includes/class-admin.php

    r3294781 r3344786  
    524524                                <button class="button" onclick="jQuery('#product-<?php echo esc_attr($product['id']); ?>').toggle();"><?php esc_html_e('Show Details', 'transfer-brands-for-woocommerce'); ?></button>
    525525                                <div id="product-<?php echo esc_attr($product['id']); ?>" style="display: none; margin-top: 10px;">
    526                                     <pre><?php print_r($product['attribute']); ?></pre>
     526                                    <?php $attr_dump = print_r($product['attribute'], true); ?>
     527                                    <pre><?php echo esc_html($attr_dump); ?></pre>
    527528                                </div>
    528529                            </td>
     
    551552                        <button class="button button-small" onclick="jQuery('#log-data-<?php echo esc_attr($index); ?>').toggle();"><?php esc_html_e('Show Data', 'transfer-brands-for-woocommerce'); ?></button>
    552553                        <div id="log-data-<?php echo esc_attr($index); ?>" style="display: none; margin-top: 5px; padding: 5px; background: #fff;">
    553                             <pre><?php print_r($entry['data']); ?></pre>
     554                            <?php $data_dump = print_r($entry['data'], true); ?>
     555                            <pre><?php echo esc_html($data_dump); ?></pre>
    554556                        </div>
    555557                        <?php endif; ?>
     
    587589     */
    588590    public function admin_page() {
    589         // Clear cache to ensure we have fresh data
    590         wp_cache_flush();
     591        // Avoid global cache flush here to prevent heavy performance impact
    591592       
    592593        // Get current tab
  • transfer-brands-for-woocommerce/trunk/includes/class-ajax.php

    r3341810 r3344786  
    585585        }
    586586       
    587         // Clear object cache
    588         wp_cache_flush();
    589        
    590587        // Delete transients that might affect the counts
    591588        delete_transient('tbfw_count_comments');
     
    593590        delete_transient('wc_term_counts');
    594591       
    595         // Clear object cache
     592        // Clear WooCommerce-related cache keys where possible without global flush
    596593        if (function_exists('wp_cache_delete')) {
    597594            wp_cache_delete('product-transient-version', 'transient');
  • transfer-brands-for-woocommerce/trunk/includes/class-core.php

    r3294781 r3344786  
    9090     */
    9191    private $debug_log = [];
     92    /**
     93     * Tracks whether the debug log has been loaded from the database
     94     * and whether a single write has been scheduled for shutdown.
     95     *
     96     * @since 2.8.1
     97     * @var bool
     98     */
     99    private $has_loaded_debug_log = false;
     100    private $has_scheduled_debug_write = false;
    92101   
    93102    /**
     
    207216            return;
    208217        }
    209        
    210         $this->debug_log = get_option('tbfw_brands_debug_log', []);
    211        
     218        // Load once per request
     219        if (!$this->has_loaded_debug_log) {
     220            $this->debug_log = get_option('tbfw_brands_debug_log', []);
     221            $this->has_loaded_debug_log = true;
     222        }
     223       
    212224        $this->debug_log[] = [
    213225            'time' => current_time('mysql'),
     
    215227            'data' => $data
    216228        ];
    217        
    218         update_option('tbfw_brands_debug_log', $this->debug_log);
     229       
     230        // Schedule a single write at shutdown instead of writing on every call
     231        if (!$this->has_scheduled_debug_write) {
     232            $this->has_scheduled_debug_write = true;
     233            add_action('shutdown', function() {
     234                // Cap the log to the most recent 1000 entries to avoid unbounded growth
     235                $log = $this->debug_log;
     236                if (is_array($log) && count($log) > 1000) {
     237                    $log = array_slice($log, -1000);
     238                }
     239                update_option('tbfw_brands_debug_log', $log);
     240            });
     241        }
    219242    }
    220243   
  • transfer-brands-for-woocommerce/trunk/readme.txt

    r3341810 r3344786  
    44Requires at least: 6.0
    55Tested up to: 6.8.2
    6 Stable tag: 2.8.0
     6Stable tag: 2.8.1
    77Requires PHP: 7.4
    88License: GPLv2 or later
  • transfer-brands-for-woocommerce/trunk/transfer-brands-for-woocommerce.php

    r3341810 r3344786  
    44 * Plugin URI: https://pluginatlas.com/transfer-brands-for-woocommerce
    55 * Description: Official migration tool for WooCommerce 9.6 Brands. Safely transfer your product brand attributes to the new brand taxonomy with image support, batch processing, and full backup capabilities.
    6  * Version: 2.8.0
     6 * Version: 2.8.1
    77 * Requires at least: 6.0
    88 * Requires PHP: 7.4
     
    3636
    3737// Define plugin constants
    38 define('TBFW_VERSION', '2.8.0');
     38define('TBFW_VERSION', '2.8.1');
    3939define('TBFW_PLUGIN_DIR', plugin_dir_path(__FILE__));
    4040define('TBFW_PLUGIN_URL', plugin_dir_url(__FILE__));
     
    155155        ]);
    156156    }
     157
     158    // Ensure debug-related options exist and are not autoloaded to avoid slow autoload queries
     159    if (false === get_option('tbfw_brands_debug_log', false)) {
     160        add_option('tbfw_brands_debug_log', [], '', 'no');
     161    } else {
     162        // If it exists but might be autoloaded, switch to non-autoloaded
     163        update_option('tbfw_brands_debug_log', get_option('tbfw_brands_debug_log', []), false);
     164    }
     165
     166    // Pre-create heavy options as non-autoloaded to prevent loading on every request
     167    if (false === get_option('tbfw_backup', false)) {
     168        add_option('tbfw_backup', [], '', 'no');
     169    } else {
     170        update_option('tbfw_backup', get_option('tbfw_backup', []), false);
     171    }
     172
     173    if (false === get_option('tbfw_term_mappings', false)) {
     174        add_option('tbfw_term_mappings', [], '', 'no');
     175    } else {
     176        update_option('tbfw_term_mappings', get_option('tbfw_term_mappings', []), false);
     177    }
     178
     179    if (false === get_option('tbfw_deleted_brands_backup', false)) {
     180        add_option('tbfw_deleted_brands_backup', [], '', 'no');
     181    } else {
     182        update_option('tbfw_deleted_brands_backup', get_option('tbfw_deleted_brands_backup', []), false);
     183    }
     184
     185    if (false === get_option('tbfw_brands_processed_ids', false)) {
     186        add_option('tbfw_brands_processed_ids', [], '', 'no');
     187    } else {
     188        update_option('tbfw_brands_processed_ids', get_option('tbfw_brands_processed_ids', []), false);
     189    }
     190
     191    if (false === get_option('tbfw_backup_cleanup_log', false)) {
     192        add_option('tbfw_backup_cleanup_log', [], '', 'no');
     193    } else {
     194        update_option('tbfw_backup_cleanup_log', get_option('tbfw_backup_cleanup_log', []), false);
     195    }
    157196   
    158197    // Flush rewrite rules
Note: See TracChangeset for help on using the changeset viewer.