File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
plugins/wpgraphql-logging/src Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,9 @@ public function column_query( DatabaseEntity $item ): ?string {
276276 */
277277 public function get_query (DatabaseEntity $ item ): string {
278278 $ query = $ item ->get_query ();
279+ if (! is_string ($ query ) || '' === $ query ) {
280+ return '' ;
281+ }
279282 return $ this ->format_code ( $ query );
280283 }
281284
@@ -331,11 +334,18 @@ public function get_request_headers(DatabaseEntity $item): string {
331334 return $ this ->format_code ( $ formatted_request_headers );
332335 }
333336
337+ /**
338+ * Format code for display in a table cell.
339+ *
340+ * @param string $code The code to format.
341+ *
342+ * @return string The formatted code.
343+ */
334344 protected function format_code (string $ code ): string {
335345 if ( empty ( $ code ) ) {
336346 return '' ;
337347 }
338- return '<pre style="overflow-x: auto; background: #f4f4f4; padding: 15px; border: 1px solid #ddd; border-radius: 4px; max-height: 300px;"> ' . esc_html ( $ code ) . '</pre> ' ;
348+ return '<pre style="overflow-x: auto; background: #f4f4f4; padding: 15px; border: 1px solid #ddd; border-radius: 4px; max-height: 300px;"> ' . esc_html ( $ code ) . '</pre> ' ;
339349 }
340350
341351 /**
Original file line number Diff line number Diff line change @@ -236,11 +236,17 @@ public function get_datetime(): string {
236236 return $ this ->datetime ;
237237 }
238238
239+ /**
240+ * Extracts and returns the GraphQL query from the context, if available.
241+ *
242+ * @phpcs:disable SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
243+ *
244+ * @return string|null The GraphQL query string, or null if not available.
245+ */
239246 public function get_query (): ?string {
240247
241- $ extra = $ this ->get_extra ();
242248 $ context = $ this ->get_context ();
243- if ( empty ( $ context ) || ! is_array ( $ context ) ) {
249+ if ( empty ( $ context ) ) {
244250 return null ;
245251 }
246252
@@ -255,6 +261,7 @@ public function get_query(): ?string {
255261 if ( empty ( $ params ) || ! is_array ( $ params ) ) {
256262 return $ query ;
257263 }
264+
258265 if ( isset ( $ params ['query ' ] ) && is_string ( $ params ['query ' ] ) ) {
259266 return $ params ['query ' ];
260267 }
You can’t perform that action at this time.
0 commit comments