Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55330 new enhancement

Set global_styles_svg_filters transient to return true causing symbol `1` to be appeared on the screen in a production mode

Reported by: aliakseyenkaihar's profile aliakseyenkaihar Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version: 5.9.1
Component: General Keywords:
Focuses: Cc:


WordPress 5.9.1
PHP 8.0.15

When I set global_styles_svg_filters to return true (to prevent from being set - I don't use theme.json but request is sending so I want to disable it) it renders 1 at the top of the website

Steps to reproduce on TwentyTwentyTwo theme:

  1. Paste these lines in functions.php
// @see
$theme = get_stylesheet();
add_filter( "pre_transient_global_styles_svg_filters_{$theme}", '__return_true' );

You will see 1 at the top of any screen on site's front

If you define WP_DEBUG as true or WP_ENVIRONMENT_TYPE as development it will dissapear

It happens [here]( - wp_get_global_styles_svg_filters() function will return true (as I manually set transient) so $cached [will]( be true as well. Therefore it echoing as 1

It is so minor and specific but it happened to me :) So because I may set any return type for this transient my guess there is no need for extra check but for a filter. For example

// script-loader.php
$svg_filters = wp_get_global_styles_svg_filters();
$filters = apply_filters( 'wp_get_global_styles_svg_filters', $svg_filters );

This way I will control svg filters output myself

Change History (2)

#1 @vijayhardaha
2 years ago

Hey @aliakseyenkaihar, May I ask why __return_true instead of setting __return_false ? as you mentioned to prevent from being set that can be done by setting false, since you're setting it true that's validated the if condition and you returned content is being printed as 1.

#2 @aliakseyenkaihar
2 years ago

Hey @vijayhardaha

I'm actually need anything but false to satisfy false !== $pre condition. See [here]( I tested with null - 1 is NOT appearing but the call to update transient is present - and my personal goal is to prevent it

Note: See TracTickets for help on using tickets.