Skip to content

Commit 672ff20

Browse files
committed
Merge branch 'doing-it-wrong-loops' into develop
2 parents 05d07df + ca4224b commit 672ff20

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

collectors/doing_it_wrong.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class QM_Collector_Doing_It_Wrong extends QM_DataCollector {
1616

1717
public $id = 'doing_it_wrong';
1818

19+
/**
20+
* @var bool
21+
*/
22+
private $collecting = false;
23+
1924
public function get_storage(): QM_Data {
2025
return new QM_Data_Doing_It_Wrong();
2126
}
@@ -112,6 +117,12 @@ public function get_concerned_filters() {
112117
* @return void
113118
*/
114119
public function action_doing_it_wrong_run( $function_name, $message, $version ) {
120+
if ( $this->collecting ) {
121+
return;
122+
}
123+
124+
$this->collecting = true;
125+
115126
$trace = new QM_Backtrace( array(
116127
'ignore_hook' => array(
117128
current_action() => true,
@@ -135,6 +146,8 @@ public function action_doing_it_wrong_run( $function_name, $message, $version )
135146
$version
136147
),
137148
);
149+
150+
$this->collecting = false;
138151
}
139152

140153
/**
@@ -144,6 +157,12 @@ public function action_doing_it_wrong_run( $function_name, $message, $version )
144157
* @return void
145158
*/
146159
public function action_deprecated_function_run( $function_name, $replacement, $version ) {
160+
if ( $this->collecting ) {
161+
return;
162+
}
163+
164+
$this->collecting = true;
165+
147166
$trace = new QM_Backtrace( array(
148167
'ignore_hook' => array(
149168
current_action() => true,
@@ -173,6 +192,8 @@ public function action_deprecated_function_run( $function_name, $replacement, $v
173192
'component' => $trace->get_component(),
174193
'message' => $message,
175194
);
195+
196+
$this->collecting = false;
176197
}
177198

178199
/**
@@ -182,6 +203,12 @@ public function action_deprecated_function_run( $function_name, $replacement, $v
182203
* @return void
183204
*/
184205
public function action_deprecated_constructor_run( $class_name, $version, $parent_class ) {
206+
if ( $this->collecting ) {
207+
return;
208+
}
209+
210+
$this->collecting = true;
211+
185212
$trace = new QM_Backtrace( array(
186213
'ignore_hook' => array(
187214
current_action() => true,
@@ -213,6 +240,8 @@ public function action_deprecated_constructor_run( $class_name, $version, $paren
213240
'component' => $trace->get_component(),
214241
'message' => $message,
215242
);
243+
244+
$this->collecting = false;
216245
}
217246

218247
/**
@@ -223,6 +252,12 @@ public function action_deprecated_constructor_run( $class_name, $version, $paren
223252
* @return void
224253
*/
225254
public function action_deprecated_file_included( $file, $replacement, $version, $message ) {
255+
if ( $this->collecting ) {
256+
return;
257+
}
258+
259+
$this->collecting = true;
260+
226261
$trace = new QM_Backtrace( array(
227262
'ignore_hook' => array(
228263
current_action() => true,
@@ -254,6 +289,8 @@ public function action_deprecated_file_included( $file, $replacement, $version,
254289
'component' => $trace->get_component(),
255290
'message' => $message,
256291
);
292+
293+
$this->collecting = false;
257294
}
258295

259296
/**
@@ -263,6 +300,12 @@ public function action_deprecated_file_included( $file, $replacement, $version,
263300
* @return void
264301
*/
265302
public function action_deprecated_argument_run( $function_name, $message, $version ) {
303+
if ( $this->collecting ) {
304+
return;
305+
}
306+
307+
$this->collecting = true;
308+
266309
$trace = new QM_Backtrace( array(
267310
'ignore_hook' => array(
268311
current_action() => true,
@@ -292,6 +335,8 @@ public function action_deprecated_argument_run( $function_name, $message, $versi
292335
'component' => $trace->get_component(),
293336
'message' => $message,
294337
);
338+
339+
$this->collecting = false;
295340
}
296341

297342
/**
@@ -302,6 +347,12 @@ public function action_deprecated_argument_run( $function_name, $message, $versi
302347
* @return void
303348
*/
304349
public function action_deprecated_hook_run( $hook, $replacement, $version, $message ) {
350+
if ( $this->collecting ) {
351+
return;
352+
}
353+
354+
$this->collecting = true;
355+
305356
$trace = new QM_Backtrace( array(
306357
'ignore_hook' => array(
307358
current_action() => true,
@@ -333,6 +384,8 @@ public function action_deprecated_hook_run( $hook, $replacement, $version, $mess
333384
'component' => $trace->get_component(),
334385
'message' => $message,
335386
);
387+
388+
$this->collecting = false;
336389
}
337390

338391
}

0 commit comments

Comments
 (0)