[wp-trac] [WordPress Trac] #54844: Unnecessary database queries when a block theme isn't in use
WordPress Trac
noreply at wordpress.org
Fri Feb 4 12:26:18 UTC 2022
#54844: Unnecessary database queries when a block theme isn't in use
--------------------------+------------------------------------
Reporter: johnbillion | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.9.1
Component: Query | Version: 5.8
Severity: normal | Resolution:
Keywords: has-patch | Focuses: template, performance
--------------------------+------------------------------------
Comment (by costdev):
Hi @dolphingg,
I'm not opposed to changing `get_theme_support` to
`current_theme_supports` (I've used `current_` in the comments above),
however I would highlight two things here:
1. `get_theme_support()` returns `array` on success, which is a truthy
value. In this sense, there is no difference when used in the context of a
truthy condition.
2. `current_theme_supports()` performs an additional check prior to
checking if `$_wp_theme_features[ $feature ] )` is set, so using
`get_theme_support()` in an `if` statement ''should'' be ''slightly'' more
performant.
Having said that, using `get_theme_support()` is a micro-optimization,
which isn't necessarily a bad thing given the subject of the ticket, but
`current_theme_supports()` is better for readability in this context.
I'm happy to go with the consensus on this.
In terms of the `Version`, this refers to when the unnecessary queries
were introduced, not when a potential solution, i.e `wp_is_block_theme()`,
became available.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54844#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list