[wp-trac] [WordPress Trac] #56758: Performance: Avoid extra calls to realpath

WordPress Trac noreply at wordpress.org
Fri Oct 7 15:44:45 UTC 2022


#56758: Performance: Avoid extra calls to realpath
--------------------------+-----------------------------
 Reporter:  aristath      |       Owner:  SergeyBiryukov
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  6.1
Component:  General       |     Version:  trunk
 Severity:  normal        |  Resolution:  fixed
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+-----------------------------
Changes (by SergeyBiryukov):

 * status:  accepted => closed
 * resolution:   => fixed


Comment:

 In [changeset:"54415" 54415]:
 {{{
 #!CommitTicketReference repository="" revision="54415"
 Blocks: Avoid extra calls to `realpath()` in block scripts and styles
 registration.

 This affects:
 * `register_block_script_handle()`
 * `register_block_style_handle()`

 Both functions set a variable with this code:
 {{{
 $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) );
 }}}

 That value never changes during page load, so we can save it to a static
 variable. By doing so, we can avoid ~200 calls to `realpath()` and
 `wp_normalize_path()`, or even more if third-party plugins register
 scripts or styles.

 Follow-up to [52291], [52939], [54290], [54291], [54309], [54327].

 Props aristath, mukesh27, SergeyBiryukov.
 Fixes #56758.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56758#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list