diff --git a/.github/ISSUE_TEMPLATE/suggest-plugin-s-option-prefix.md b/.github/ISSUE_TEMPLATE/suggest-plugin-s-option-prefix.md index b951fb4..464c571 100644 --- a/.github/ISSUE_TEMPLATE/suggest-plugin-s-option-prefix.md +++ b/.github/ISSUE_TEMPLATE/suggest-plugin-s-option-prefix.md @@ -1,6 +1,6 @@ --- name: Suggest plugin's option prefix -about: AAA Option Optimizer lists the plugin to which an option belongs, if it recognizes +about: AAA Autoload Optimizer lists the plugin to which an option belongs, if it recognizes it. title: "[Plugin Identification] Suggest plugin's option prefix" labels: enhancement diff --git a/.wordpress-org/banner-1544x500-nl_NL.png b/.wordpress-org/banner-1544x500-nl_NL.png new file mode 100644 index 0000000..8512b4f Binary files /dev/null and b/.wordpress-org/banner-1544x500-nl_NL.png differ diff --git a/.wordpress-org/banner-1544x500.png b/.wordpress-org/banner-1544x500.png index e8918d7..9110663 100644 Binary files a/.wordpress-org/banner-1544x500.png and b/.wordpress-org/banner-1544x500.png differ diff --git a/.wordpress-org/banner-772x250-nl_NL.png b/.wordpress-org/banner-772x250-nl_NL.png new file mode 100644 index 0000000..a992aa3 Binary files /dev/null and b/.wordpress-org/banner-772x250-nl_NL.png differ diff --git a/.wordpress-org/banner-772x250.png b/.wordpress-org/banner-772x250.png index a10bbc5..f710255 100644 Binary files a/.wordpress-org/banner-772x250.png and b/.wordpress-org/banner-772x250.png differ diff --git a/.wordpress-org/github_banner_aaaao_pp.png b/.wordpress-org/github_banner_aaaao_pp.png new file mode 100644 index 0000000..ec11588 Binary files /dev/null and b/.wordpress-org/github_banner_aaaao_pp.png differ diff --git a/.wordpress-org/github_banner_aaaoo_pp.png b/.wordpress-org/github_banner_aaaoo_pp.png deleted file mode 100644 index 32efae9..0000000 Binary files a/.wordpress-org/github_banner_aaaoo_pp.png and /dev/null differ diff --git a/README.md b/README.md index 463dd10..cba8259 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ [![Try this plugin on the WordPress playground](https://img.shields.io/badge/Try%20this%20plugin%20on%20the%20WordPress%20Playground-%23117AC9.svg?style=for-the-badge&logo=WordPress&logoColor=ddd)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/tools.php?page=aaa-option-optimizer%22,%22features%22:%7B%22networking%22:true%7D,%22steps%22:%5B%7B%22step%22:%22defineWpConfigConsts%22,%22consts%22:%7B%22IS_PLAYGROUND_PREVIEW%22:true%7D%7D,%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22url%22,%22url%22:%22https://bypass-cors.altha.workers.dev/https://github.com/ProgressPlanner/aaa-option-optimizer/archive/refs/heads/develop.zip%22%7D,%22options%22:%7B%22activate%22:true%7D%7D%5D%7D) -![GitHub banner](/.wordpress-org/github_banner_aaaoo_pp.png) +![GitHub banner](/.wordpress-org/github_banner_aaaao_pp.png) -# AAA Option Optimizer +# AAA Autoload Optimizer This plugin tracks which of the autoloaded options are used on a page, and stores that data at the end of page render. It keeps an array of options that it has seen as being used. On the admin page, it compares all the autoloaded options to the array of stored options, and shows the autoloaded options that have not been used as you were browsing the site. If you've been to every page on your site, or you've kept the plugin around for a week or so, this means that those options probably don't need to be autoloaded. ## How to use this plugin diff --git a/aaa-option-optimizer.php b/aaa-option-optimizer.php index 3bacb4d..4a48511 100644 --- a/aaa-option-optimizer.php +++ b/aaa-option-optimizer.php @@ -4,13 +4,13 @@ * * @package Progress_Planner\OptionOptimizer * - * Plugin Name: AAA Option Optimizer + * Plugin Name: AAA Autoload Optimizer * Plugin URI: https://progressplanner.com/plugins/aaa-option-optimizer/ * Description: Tracks autoloaded options usage and allows the user to optimize them. - * Version: 1.6.1 + * Version: 1.7.0 * License: GPL-3.0+ - * Author: Team Prospress Planner - * Author URI: https://prospressplanner.com/ + * Author: Team Progress Planner + * Author URI: https://progressplanner.com/ * Text Domain: aaa-option-optimizer */ diff --git a/composer.json b/composer.json index 8ee7555..c1643cc 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ "php-parallel-lint/php-parallel-lint": "^1.3", "phpcompatibility/phpcompatibility-wp": "^2.1", "wp-coding-standards/wpcs": "^3.0", - "phpstan/phpstan": "^1.10", - "szepeviktor/phpstan-wordpress": "^1.3", + "phpstan/phpstan": "^2.0", + "szepeviktor/phpstan-wordpress": "^2.0", "phpstan/extension-installer": "^1.3", "phpcompatibility/php-compatibility": "^9.3" }, diff --git a/composer.lock b/composer.lock index d186fc9..4eeceb4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "68e73cf23844dd66f4d8b3b14eef46cd", + "content-hash": "49309948e892429c2a9f26b0e665194e", "packages": [], "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v1.2.0", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/composer-installer.git", - "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1" + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1", - "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/963f0c67bffde0eac41b56be71ac0e8ba132f0bd", + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd", "shasum": "" }, "require": { @@ -101,7 +101,7 @@ "type": "thanks_dev" } ], - "time": "2025-11-11T04:32:07+00:00" + "time": "2026-05-06T08:26:05+00:00" }, { "name": "php-parallel-lint/php-parallel-lint", @@ -166,16 +166,16 @@ }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.9.0", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "5171cb6650e6c583a96943fd6ea0dfa3e1089a8a" + "reference": "6926c5156431a3ff909d43faa16a92a0bc0c2428" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/5171cb6650e6c583a96943fd6ea0dfa3e1089a8a", - "reference": "5171cb6650e6c583a96943fd6ea0dfa3e1089a8a", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6926c5156431a3ff909d43faa16a92a0bc0c2428", + "reference": "6926c5156431a3ff909d43faa16a92a0bc0c2428", "shasum": "" }, "conflict": { @@ -185,12 +185,13 @@ "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "nikic/php-parser": "^5.5", "php": "^7.4 || ^8.0", - "php-stubs/generator": "^0.8.3", - "phpdocumentor/reflection-docblock": "^5.4.1", - "phpstan/phpstan": "^2.1", + "php-stubs/generator": "^0.9", + "phpdocumentor/reflection-docblock": "^6.0", + "phpstan/phpstan": "^2.2", "phpunit/phpunit": "^9.5", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", - "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + "symfony/polyfill-php80": "*", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.2", + "wp-coding-standards/wpcs": "3.4.1 as 2.3.0" }, "suggest": { "paragonie/sodium_compat": "Pure PHP implementation of libsodium", @@ -211,9 +212,9 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.9.0" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v7.1.2" }, - "time": "2025-12-03T23:06:24+00:00" + "time": "2026-10-06T06:59:21+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -430,21 +431,21 @@ }, { "name": "phpcsstandards/phpcsextra", - "version": "1.5.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "b598aa890815b8df16363271b659d73280129101" + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/b598aa890815b8df16363271b659d73280129101", - "reference": "b598aa890815b8df16363271b659d73280129101", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/39467533fdb742446d68c1d10ac33d625ee0311c", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c", "shasum": "" }, "require": { "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.2.0", + "phpcsstandards/phpcsutils": "^1.2.3", "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" }, "require-dev": { @@ -508,20 +509,20 @@ "type": "thanks_dev" } ], - "time": "2025-11-12T23:06:57+00:00" + "time": "2026-07-27T11:13:17+00:00" }, { "name": "phpcsstandards/phpcsutils", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55" + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", - "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/5f35d9408c54d7b529501f3c688b6eae562aea1f", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f", "shasum": "" }, "require": { @@ -601,7 +602,7 @@ "type": "thanks_dev" } ], - "time": "2025-12-08T14:27:58+00:00" + "time": "2026-07-27T10:28:41+00:00" }, { "name": "phpstan/extension-installer", @@ -653,15 +654,15 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.32", + "version": "2.3.0", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8", - "reference": "2770dcdf5078d0b0d53f94317e06affe88419aa8", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b1f9890d9af53a25c58129e78f0aadd31f90d7f4", + "reference": "b1f9890d9af53a25c58129e78f0aadd31f90d7f4", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -680,6 +681,17 @@ "license": [ "MIT" ], + "authors": [ + { + "name": "Ondřej Mirtes" + }, + { + "name": "Markus Staab" + }, + { + "name": "Vincent Langlet" + } + ], "description": "PHPStan - PHP Static Analysis Tool", "keywords": [ "dev", @@ -702,7 +714,7 @@ "type": "github" } ], - "time": "2025-09-30T10:16:31+00:00" + "time": "2026-10-06T06:15:36+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -783,112 +795,32 @@ ], "time": "2025-11-04T16:30:35+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.33.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", - "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, { "name": "szepeviktor/phpstan-wordpress", - "version": "v1.3.5", + "version": "v2.0.4", "source": { "type": "git", "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7" + "reference": "84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/7f8cfe992faa96b6a33bbd75c7bace98864161e7", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a", + "reference": "84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", - "phpstan/phpstan": "^1.10.31", - "symfony/polyfill-php73": "^1.12.0" + "php": "^7.4 || ^8.0", + "php-stubs/wordpress-stubs": ">=6.6.2", + "phpstan/phpstan": "^2.0" }, "require-dev": { "composer/composer": "^2.1.14", + "composer/semver": "^3.4", "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.1", - "phpstan/phpstan-strict-rules": "^1.2", - "phpunit/phpunit": "^8.0 || ^9.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.0", "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" }, @@ -922,22 +854,22 @@ ], "support": { "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", - "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.5" + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v2.0.4" }, - "time": "2024-06-28T22:27:19+00:00" + "time": "2026-05-22T16:22:09+00:00" }, { "name": "wp-coding-standards/wpcs", - "version": "3.3.0", + "version": "3.4.1", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7795ec6fa05663d716a549d0b44e47ffc8b0d4a6" + "reference": "ec2ff942335f33683a5957a85d138753876a05cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7795ec6fa05663d716a549d0b44e47ffc8b0d4a6", - "reference": "7795ec6fa05663d716a549d0b44e47ffc8b0d4a6", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/ec2ff942335f33683a5957a85d138753876a05cf", + "reference": "ec2ff942335f33683a5957a85d138753876a05cf", "shasum": "" }, "require": { @@ -946,9 +878,9 @@ "ext-tokenizer": "*", "ext-xmlreader": "*", "php": ">=7.2", - "phpcsstandards/phpcsextra": "^1.5.0", - "phpcsstandards/phpcsutils": "^1.1.0", - "squizlabs/php_codesniffer": "^3.13.4" + "phpcsstandards/phpcsextra": "^1.5.1", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5" }, "require-dev": { "php-parallel-lint/php-console-highlighter": "^1.0.0", @@ -990,7 +922,7 @@ "type": "custom" } ], - "time": "2025-11-25T12:08:04+00:00" + "time": "2026-07-27T11:53:23+00:00" } ], "aliases": [], diff --git a/known-plugins/known-plugins.json b/known-plugins/known-plugins.json index a0d3d9f..6ec26a8 100644 --- a/known-plugins/known-plugins.json +++ b/known-plugins/known-plugins.json @@ -1,6 +1,6 @@ { "aaa-option-optimizer": { - "name": "AAA Option Optimizer", + "name": "AAA Autoload Optimizer", "option_prefixes": ["option_optimizer"] }, "accessibility-checker": { diff --git a/package-lock.json b/package-lock.json index 4e43350..e0787cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "aaa-option-optimizer", - "version": "1.3.2", + "version": "1.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "aaa-option-optimizer", - "version": "1.3.2", + "version": "1.7.0", "license": "GPL-3.0-or-later", "devDependencies": { "@playwright/test": "^1.42.1", diff --git a/package.json b/package.json index fbb7c4a..a00a93d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aaa-option-optimizer", - "version": "1.3.2", + "version": "1.7.0", "private": true, "description": "WordPress plugin", "author": "Team Emilia Projects", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 7c4ebd2..847d18c 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,7 +1,7 @@ - + - A custom set of rules to check for the AAA Option Optimizer project + A custom set of rules to check for the AAA Autoload Optimizer project + == Changelog == += 1.7.0 = + +* Rename the plugin to AAA Autoload Optimizer. +* Fix database deadlocks when concurrent requests write tracked options. +* Fix a fatal error when W3 Total Cache's database cache is active. +* Readme improvements. + = 1.6.1 = -* Fix infinite recursion in option access monitoring that could cause a fatal error in certain hosting environments. +* Fix infinite recursion in option access monitoring that could cause a + fatal error in certain hosting environments. -= 1.6.0 += 1.6.0 = -* Replace using 'all' filter for monitoring option usage with 'pre_option' filter for better performance. -* Migrate tracked options data from a single wp_option to a custom database table for improved performance and reliability. +* Replace using 'all' filter for monitoring option usage with + 'pre_option' filter for better performance. +* Migrate tracked options data from a single wp_option to a custom + database table for improved performance and reliability. = 1.5.1 = @@ -104,42 +218,76 @@ Please do a pull request via GitHub on [this file](https://github.com/ProgressPl Enhancements: * Overhaul of the UX, implementing proper tabs, better buttons and more. -* Added a new "All options" tab, which, when you hit the button, loads all the options from the database and allows you to manage them. +* Added a new "All options" tab, which, when you hit the button, loads + all the options from the database and allows you to manage them. * Added a "Reset data" button which resets the tracking data. * Added a link to the Optimize Options page from the Plugins page. -* Much improved recognition of core WordPress options, themes and plugins under "Source", thanks in part to pull requests from [Rogier Lankhorst](https://profiles.wordpress.org/rogierlankhorst/) and [system4pc](https://github.com/system4pc). -* You can now also filter all tables by Source so you can more easily find the options you're looking for. -* Many code and speed improvements under the hood, including adding a class autoloader and some i18n fixes. +* Much improved recognition of core WordPress options, themes and plugins + under "Source", thanks in part to pull requests from + [Rogier Lankhorst](https://profiles.wordpress.org/rogierlankhorst/) + and [system4pc](https://github.com/system4pc). +* You can now also filter all tables by Source so you can more easily + find the options you're looking for. +* Many code and speed improvements under the hood, including adding a + class autoloader and some i18n fixes. = 1.1.1 = -Implement the missing functionality to create an option with value `false` when it's being loaded but doesn't exist. +Implement the missing functionality to create an option with value +`false` when it's being loaded but doesn't exist. = 1.1 = -The plugin now recognizes plugins from which the options came (thanks to a great pull by [Rogier Lankhorst](https://profiles.wordpress.org/rogierlankhorst/)). If you're a plugin developer and want your plugin's options -properly recognized, please do a pull request [on this file](https://github.com/ProgressPlanner/aaa-option-optimizer/blob/main/known-plugins/known-plugins.json). +The plugin now recognizes plugins from which the options came (thanks to +a great pull by +[Rogier Lankhorst](https://profiles.wordpress.org/rogierlankhorst/)). +If you're a plugin developer and want your plugin's options properly +recognized, please do a pull request on +[this file](https://github.com/ProgressPlanner/aaa-option-optimizer/blob/main/known-plugins/known-plugins.json). Small enhancements: -* Column width is now automatically determined which leads to better spacing. +* Column width is now automatically determined which leads to better + spacing. * Action buttons are now centered in their columns. Bugs fixed: -* If you removed autoload from or deleted an option, it'd be removed from the table but would be back when you paginated, that's fixed - thanks to [Jono Alderson](https://profiles.wordpress.org/jonoaldersonwp/) for reporting. -* Fixed sorting by filesize by moving the `KB` to the table heading, so that you can now properly sort numbers. +* If you removed autoload from or deleted an option, it'd be removed + from the table but would be back when you paginated, that's fixed - + thanks to + [Jono Alderson](https://profiles.wordpress.org/jonoaldersonwp/) + for reporting. +* Fixed sorting by filesize by moving the `KB` to the table heading, so + that you can now properly sort numbers. * Fixed issue where an empty option would result in weird size output. = 1.0.2 = * Fixed a bug where the buttons wouldn't work in a paginated state. -* Show the value of an option in a `popover`, as suggested with a great pull request by [@rogierlankhorst](https://profiles.wordpress.org/rogierlankhorst/). +* Show the value of an option in a `popover`, as suggested with a great + pull request by + [@rogierlankhorst](https://profiles.wordpress.org/rogierlankhorst/). = 1.0.1 = -Fixed an error with values that are objects, not strings, which also caused sorting not to work for some people. +Fixed an error with values that are objects, not strings, which also +caused sorting not to work for some people. = 1.0 = Initial release on GitHub and WordPress.org. + +== Upgrade Notice == + += 1.7.0 = +The plugin is now called AAA Autoload Optimizer. Also fixes bugs with +concurrent requests and W3 Total Cache. + += 1.6.1 = +Fixes a potential fatal error from infinite recursion in option +monitoring on certain hosts. + += 1.6.0 = +Performance and reliability: option tracking now uses a custom database +table instead of a single wp_option. diff --git a/src/class-admin-page.php b/src/class-admin-page.php index e45a243..7512fa0 100644 --- a/src/class-admin-page.php +++ b/src/class-admin-page.php @@ -1,6 +1,6 @@
-

+

@@ -306,7 +306,7 @@ public function render_admin_page_ajax() {

-

+

@@ -347,7 +347,7 @@ public function render_admin_page_ajax() {

-

+

@@ -389,7 +389,7 @@ public function render_admin_page_ajax() {

-

+

diff --git a/src/class-database.php b/src/class-database.php index 16c5793..962bc1d 100644 --- a/src/class-database.php +++ b/src/class-database.php @@ -1,6 +1,6 @@ $options Array of option_name => count. * @param int $chunk_size Number of options per query. Default 500. * * @return void */ public static function batch_insert( $options, $chunk_size = 500 ) { - global $wpdb; - if ( empty( $options ) ) { return; } + // SORT_STRING: numeric option names become int keys, keep one total order. + \ksort( $options, SORT_STRING ); + + // A deadlock rolls back the whole transaction, so one retry can't double count. + if ( ! self::write_chunks( $options, $chunk_size ) && self::last_error_is_deadlock() ) { + self::write_chunks( $options, $chunk_size ); + } + } + + /** + * Write option counts in chunks inside a single transaction. + * + * @param array $options Array of option_name => count, already sorted. + * @param int $chunk_size Number of options per query. + * + * @return bool Whether the transaction was committed. + */ + private static function write_chunks( $options, $chunk_size ) { + global $wpdb; + $table_name = self::get_table_name(); + // Use `START TRANSACTION` (not `BEGIN`) so W3 Total Cache's DbCache layer + // recognizes it as a transaction and skips caching — `BEGIN` slips past its + // regex and triggers a fatal in wpdb::load_col_info() on the boolean result. // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching - $wpdb->query( 'BEGIN' ); + $wpdb->query( 'START TRANSACTION' ); foreach ( array_chunk( $options, $chunk_size, true ) as $chunk ) { $values = []; @@ -204,7 +230,7 @@ public static function batch_insert( $options, $chunk_size = 500 ) { foreach ( $chunk as $option_name => $count ) { $placeholders[] = '(%s, %d, NOW())'; - $values[] = $option_name; + $values[] = (string) $option_name; $values[] = (int) $count; } @@ -213,11 +239,29 @@ public static function batch_insert( $options, $chunk_size = 500 ) { ON DUPLICATE KEY UPDATE access_count = access_count + VALUES(access_count)'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared - $wpdb->query( $wpdb->prepare( $sql, ...$values ) ); + if ( false === $wpdb->query( $wpdb->prepare( $sql, ...$values ) ) ) { + // Keep the error: ROLLBACK succeeding would clear `$wpdb->last_error`. + $error = $wpdb->last_error; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $wpdb->query( 'ROLLBACK' ); + $wpdb->last_error = $error; + return false; + } } // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching - $wpdb->query( 'COMMIT' ); + return false !== $wpdb->query( 'COMMIT' ); + } + + /** + * Whether the last database error was an InnoDB deadlock (MySQL error 1213). + * + * @return bool + */ + private static function last_error_is_deadlock() { + global $wpdb; + + return false !== \stripos( (string) $wpdb->last_error, 'Deadlock found' ); } /** diff --git a/src/class-plugin.php b/src/class-plugin.php index 7213d73..d73be85 100644 --- a/src/class-plugin.php +++ b/src/class-plugin.php @@ -1,6 +1,6 @@