Skip to content

Commit 3816c87

Browse files
authored
Merge pull request #75 from ProgressPlanner/develop
v1.6.1
2 parents 9372cb3 + d82fac1 commit 3816c87

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

aaa-option-optimizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Plugin Name: AAA Option Optimizer
88
* Plugin URI: https://progressplanner.com/plugins/aaa-option-optimizer/
99
* Description: Tracks autoloaded options usage and allows the user to optimize them.
10-
* Version: 1.6.0
10+
* Version: 1.6.1
1111
* License: GPL-3.0+
1212
* Author: Team Prospress Planner
1313
* Author URI: https://prospressplanner.com/

readme.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
=== AAA Option Optimizer ===
2-
Contributors: joostdevalk, aristath, filipi
2+
Contributors: joostdevalk, aristath, filipi, progressplanner
33
Tags: options, database, cleanup
44
Requires at least: 6.7
55
Tested up to: 7.0
66
Requires PHP: 7.4
7-
Stable tag: 1.6.0
7+
Stable tag: 1.6.1
88
License: GPL3+
99
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
1010

@@ -54,6 +54,10 @@ Please do a pull request via GitHub on [this file](https://github.com/ProgressPl
5454

5555
== Changelog ==
5656

57+
= 1.6.1 =
58+
59+
* Fix infinite recursion in option access monitoring that could cause a fatal error in certain hosting environments.
60+
5761
= 1.6.0
5862

5963
* Replace using 'all' filter for monitoring option usage with 'pre_option' filter for better performance.

src/class-plugin.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ class Plugin {
2525
*/
2626
protected $accessed_options = [];
2727

28+
/**
29+
* Whether the plugin is currently processing an option access.
30+
* Used to prevent infinite recursion.
31+
*
32+
* @var bool
33+
*/
34+
protected $is_processing = false;
35+
2836
/**
2937
* Whether the plugin should reset the option_optimizer data.
3038
*
@@ -101,10 +109,16 @@ public function reset( $should_reset = true ) {
101109
* @return void
102110
*/
103111
public function monitor_option_accesses_legacy( $tag ) {
112+
if ( $this->is_processing ) {
113+
return;
114+
}
115+
104116
// Check if the tag is related to an option access.
105117
if ( str_starts_with( $tag, 'option_' ) || str_starts_with( $tag, 'default_option_' ) ) {
106-
$option_name = preg_replace( '#^(default_)?option_#', '', $tag );
118+
$this->is_processing = true;
119+
$option_name = preg_replace( '#^(default_)?option_#', '', $tag );
107120
$this->add_option_usage( $option_name );
121+
$this->is_processing = false;
108122
}
109123
}
110124

@@ -117,10 +131,15 @@ public function monitor_option_accesses_legacy( $tag ) {
117131
* @return mixed
118132
*/
119133
public function monitor_option_accesses_pre_option( $pre, $option_name ) {
134+
if ( $this->is_processing ) {
135+
return $pre;
136+
}
120137

121138
// If the $pre is false the get_option() will not be short-circuited.
122139
if ( ! defined( 'WP_SETUP_CONFIG' ) && false === $pre ) {
140+
$this->is_processing = true;
123141
$this->add_option_usage( $option_name );
142+
$this->is_processing = false;
124143
}
125144

126145
return $pre;

0 commit comments

Comments
 (0)