Commit 78aea8b
committed
Themes: Optimize
This aims to speed up processing and reduce memory footprint when parsing the `Template Name` and `Template Post Type` headers for themes with many template files by replacing two `file_get_contents()` calls with a single `get_file_data()` call, which only reads the first 8KB of each file instead of the entire contents.
`get_file_data()` already calls `_cleanup_header_comment()` internally, so the parsed output is equivalent to the previous manual cleanup. Additionally, the `extra_theme_headers` filter is now applied, bringing consistency with parsing the other theme file headers, such as in the `WP_Theme` constructor.
Includes unit tests covering the caching behavior, cache invalidation on theme switch, and `get_file_data()` integration.
Follow-up to [20029], [20041], [20317], [20327], [20588], [38951], [62809].
Props gschoppe, MythThrazz, birgire, swissspidy, sukhendu2002, sachinrajcp123, SergeyBiryukov.
Fixes #42513.
git-svn-id: https://develop.svn.wordpress.org/trunk@62810 602fd350-edb4-49c9-b593-d223f7449a82WP_Theme::get_post_templates() for efficiency.1 parent 022155d commit 78aea8b
2 files changed
Lines changed: 83 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1338 | 1338 | | |
1339 | 1339 | | |
1340 | 1340 | | |
1341 | | - | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
1342 | 1351 | | |
1343 | 1352 | | |
1344 | 1353 | | |
1345 | 1354 | | |
1346 | | - | |
1347 | | - | |
| 1355 | + | |
| 1356 | + | |
1348 | 1357 | | |
1349 | 1358 | | |
1350 | 1359 | | |
| |||
1353 | 1362 | | |
1354 | 1363 | | |
1355 | 1364 | | |
1356 | | - | |
| 1365 | + | |
1357 | 1366 | | |
1358 | 1367 | | |
1359 | 1368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
50 | 120 | | |
0 commit comments