[wp-trac] [WordPress Trac] #42513: WP_Theme::get_post_templates() is extremely inefficient for large themes
WordPress Trac
noreply at wordpress.org
Sat Nov 11 19:32:15 UTC 2017
#42513: WP_Theme::get_post_templates() is extremely inefficient for large themes
-------------------------------------+-------------------------------------
Reporter: gschoppe | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 4.8.3
Severity: normal | Resolution:
Keywords: has-patch needs-unit- | Focuses: administration,
tests | performance
-------------------------------------+-------------------------------------
Changes (by birgire):
* keywords: => has-patch needs-unit-tests
Comment:
@gschoppe Welcome to WordPress trac.
This seems like a good catch.
This will probably need a unit test as well. There's one already for the
{{{get_post_templates()}}} method in
{{{Tests_Admin_includesTheme::test_get_post_templates_child_theme()}}} so
maybe it would cover this as well, instead of a new one?
I think I've spotted another part that could benefit from this, namely the
{{{get_file_description()}}} function, that contains:
{{{
$template_data = implode( '', file( $file_path ) );
}}}
where {{{file()}}} reads the entire file into an array.
The theme editor uses (4.9+) {{{wp_print_theme_file_tree()}}} recursively
and therefore we have multiple {{{get_file_description()}}} function
calls.
So with your suggestion of using {{{get_file_data()}}} it seems that we
could adjust {{{get_file_description()}}} as well to be more efficient.
Best create a new ticket for that, if this is the way to go here.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42513#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list