Skip to content

Commit c9eece1

Browse files
committed
Add a column to the Doing it Wrong panel for the component.
1 parent c9ca562 commit c9eece1

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

collectors/doing_it_wrong.php

+6
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public function action_doing_it_wrong_run( $function_name, $message, $version )
126126
$this->data->actions[] = array(
127127
'hook' => 'doing_it_wrong_run',
128128
'filtered_trace' => $trace->get_filtered_trace(),
129+
'component' => $trace->get_component(),
129130
'message' => sprintf(
130131
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: WordPress version number. */
131132
__( 'Function %1$s was called incorrectly. %2$s %3$s', 'query-monitor' ),
@@ -169,6 +170,7 @@ public function action_deprecated_function_run( $function_name, $replacement, $v
169170
$this->data->actions[] = array(
170171
'hook' => 'deprecated_function_run',
171172
'filtered_trace' => $trace->get_filtered_trace(),
173+
'component' => $trace->get_component(),
172174
'message' => $message,
173175
);
174176
}
@@ -208,6 +210,7 @@ public function action_deprecated_constructor_run( $class_name, $version, $paren
208210
$this->data->actions[] = array(
209211
'hook' => 'deprecated_constructor_run',
210212
'filtered_trace' => $trace->get_filtered_trace(),
213+
'component' => $trace->get_component(),
211214
'message' => $message,
212215
);
213216
}
@@ -248,6 +251,7 @@ public function action_deprecated_file_included( $file, $replacement, $version,
248251
$this->data->actions[] = array(
249252
'hook' => 'deprecated_file_included',
250253
'filtered_trace' => $trace->get_filtered_trace(),
254+
'component' => $trace->get_component(),
251255
'message' => $message,
252256
);
253257
}
@@ -285,6 +289,7 @@ public function action_deprecated_argument_run( $function_name, $message, $versi
285289
$this->data->actions[] = array(
286290
'hook' => 'deprecated_argument_run',
287291
'filtered_trace' => $trace->get_filtered_trace(),
292+
'component' => $trace->get_component(),
288293
'message' => $message,
289294
);
290295
}
@@ -325,6 +330,7 @@ public function action_deprecated_hook_run( $hook, $replacement, $version, $mess
325330
$this->data->actions[] = array(
326331
'hook' => 'deprecated_hook_run',
327332
'filtered_trace' => $trace->get_filtered_trace(),
333+
'component' => $trace->get_component(),
328334
'message' => $message,
329335
);
330336
}

data/doing_it_wrong.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
class QM_Data_Doing_It_Wrong extends QM_Data {
99
/**
10-
* @var array<int, array<string, mixed>> */
10+
* @var array<int, array<string, mixed>>
11+
* @phpstan-var array<int, array{
12+
* hook: string,
13+
* filtered_trace: list<array<string, mixed>>,
14+
* message: string,
15+
* component: QM_Component,
16+
* }>
17+
*/
1118
public $actions;
1219
}

output/html/doing_it_wrong.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function output() {
6868
echo '<tr>';
6969
echo '<th scope="col">' . esc_html__( 'Message', 'query-monitor' ) . '</th>';
7070
echo '<th scope="col">' . esc_html__( 'Caller', 'query-monitor' ) . '</th>';
71+
echo '<th scope="col">' . esc_html__( 'Component', 'query-monitor' ) . '</th>';
7172
echo '</tr>';
7273
echo '</thead>';
7374

@@ -102,15 +103,16 @@ public function output() {
102103

103104
echo '</ol></td>';
104105

105-
echo '</tr>';
106+
echo '<td class="qm-nowrap">' . esc_html( $row['component']->name ) . '</td>';
106107

108+
echo '</tr>';
107109
}
108110

109111
echo '</tbody>';
110112

111113
echo '<tfoot>';
112114
printf(
113-
'<tr><td colspan="2">%s</td></tr>',
115+
'<tr><td colspan="3">%s</td></tr>',
114116
sprintf(
115117
/* translators: %s: Total number of Doing it Wrong occurrences */
116118
esc_html_x( 'Total: %s', 'Total Doing it Wrong occurrences', 'query-monitor' ),

0 commit comments

Comments
 (0)