[wp-trac] [WordPress Trac] #62809: Optimize conditional checks and require_once logic for wp-load.php inclusion

WordPress Trac noreply at wordpress.org
Thu Jan 16 15:53:26 UTC 2025


#62809: Optimize conditional checks and require_once logic for wp-load.php
inclusion
-------------------------+-----------------------------
 Reporter:  hussain896   |       Owner:  SergeyBiryukov
     Type:  enhancement  |      Status:  reviewing
 Priority:  normal       |   Milestone:  6.8
Component:  Upload       |     Version:  6.7.1
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  administration
-------------------------+-----------------------------
Changes (by SergeyBiryukov):

 * keywords:  has-patch 2nd-opinion close => has-patch
 * owner:  (none) => SergeyBiryukov
 * status:  assigned => reviewing
 * milestone:  Awaiting Review => 6.8


Comment:

 Hi there, thanks for the ticket! Introduced in [6659] and [7971].

 In a variety of other files, including:
 {{{
 wp-admin/admin.php
 wp-admin/admin-ajax.php
 wp-admin/install.php
 wp-admin/install-helper.php
 wp-admin/maint/repair.php
 wp-admin/moderation.php
 wp-admin/tools.php
 wp-admin/upgrade.php
 wp-includes/ms-files.php
 }}}
 we just do this:
 {{{
 /** Load WordPress Bootstrap */
 require_once dirname( __DIR__ ) . '/wp-load.php';
 }}}

 Since we don't really support relocating `wp-admin` or `wp-load.php`, I
 think we can do the same here, checking for `ABSPATH` appears to be
 redundant.

 Note that the [source:tags/6.7.1/src/wp-admin/async-
 upload.php?marks=23#L17 next line] loads `wp-admin/admin.php`, which also
 loads `wp-load.php` in [source:tags/6.7.1/src/wp-
 admin/admin.php?marks=34#L33 line 34] without checking for `ABSPATH`.

 Also note that a similar fragment also exists in `wp-admin/admin-
 post.php`, introduced in [7971].

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


More information about the wp-trac mailing list