WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/27/2016 09:15:01 AM (4 years ago)
Author:
wonderboymusic
Message:

Bootstrap: Autoload classes using a Composer-generated PHP 5.2-compatible Autoloader.

  • wp-admin and wp-includes are scanned for classes to autoload
  • Several 3rd-party and Ryan McCue-shaped libraries are excluded when the classmap is generated, see composer.json: autoload.exclude-from-classmap
  • wp-vendor/autoload_52.php is included at the top of wp-settings.php - no changes need to be made to unit tests to include the autoloader
  • An avalanche of require() and require_once() calls that loaded class files have been removed from the codebase.

The following files have been added to svn:ignore - they are not 5.2-compatible and fail during pre-commit:

  • src/wp-vendor/autoload.php
  • src/wp-vendor/composer/autoload_real.php
  • src/wp-vendor/composer/autoload_static.php
  • src/wp-vendor/composer/ClassLoader.php

We favor these files instead:

  • src/wp-vendor/autoload_52.php
  • src/wp-vendor/composer/autoload_real_52.php
  • src/wp-vendor/composer/ClassLoader52.php

When new PHP classes are added to the codebase, simply run composer install or composer update from the project root to update the autoloader.

The future is now.

See #36335.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-settings.php

    r38386 r38399  
    1717 */
    1818define( 'WPINC', 'wp-includes' );
     19
     20// WordPress Core PHP 5.2-compatible Autoloader
     21require_once( ABSPATH . 'wp-vendor/autoload_52.php' );
    1922
    2023// Include files required for initialization.
     
    9497require( ABSPATH . WPINC . '/option.php' );
    9598require( ABSPATH . WPINC . '/functions.php' );
    96 require( ABSPATH . WPINC . '/class-wp-matchesmapregex.php' );
    97 require( ABSPATH . WPINC . '/class-wp.php' );
    98 require( ABSPATH . WPINC . '/class-wp-error.php' );
    9999require( ABSPATH . WPINC . '/pomo/mo.php' );
    100 require( ABSPATH . WPINC . '/class-phpass.php' );
    101100
    102101// Include the wpdb class and, if present, a db.php database drop-in.
     
    116115// Initialize multisite if enabled.
    117116if ( is_multisite() ) {
    118     require( ABSPATH . WPINC . '/class-wp-site-query.php' );
    119     require( ABSPATH . WPINC . '/class-wp-network-query.php' );
    120117    require( ABSPATH . WPINC . '/ms-blogs.php' );
    121118    require( ABSPATH . WPINC . '/ms-settings.php' );
     
    137134
    138135// Load most of WordPress.
    139 require( ABSPATH . WPINC . '/class-wp-walker.php' );
    140 require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
    141136require( ABSPATH . WPINC . '/formatting.php' );
    142137require( ABSPATH . WPINC . '/capabilities.php' );
    143 require( ABSPATH . WPINC . '/class-wp-roles.php' );
    144 require( ABSPATH . WPINC . '/class-wp-role.php' );
    145 require( ABSPATH . WPINC . '/class-wp-user.php' );
    146 require( ABSPATH . WPINC . '/class-wp-query.php' );
    147138require( ABSPATH . WPINC . '/query.php' );
    148 require( ABSPATH . WPINC . '/date.php' );
    149139require( ABSPATH . WPINC . '/theme.php' );
    150 require( ABSPATH . WPINC . '/class-wp-theme.php' );
    151140require( ABSPATH . WPINC . '/template.php' );
    152141require( ABSPATH . WPINC . '/user.php' );
    153 require( ABSPATH . WPINC . '/class-wp-user-query.php' );
    154 require( ABSPATH . WPINC . '/class-wp-session-tokens.php' );
    155 require( ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php' );
    156142require( ABSPATH . WPINC . '/meta.php' );
    157 require( ABSPATH . WPINC . '/class-wp-meta-query.php' );
    158 require( ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php' );
    159143require( ABSPATH . WPINC . '/general-template.php' );
    160144require( ABSPATH . WPINC . '/link-template.php' );
    161145require( ABSPATH . WPINC . '/author-template.php' );
    162146require( ABSPATH . WPINC . '/post.php' );
    163 require( ABSPATH . WPINC . '/class-walker-page.php' );
    164 require( ABSPATH . WPINC . '/class-walker-page-dropdown.php' );
    165 require( ABSPATH . WPINC . '/class-wp-post-type.php' );
    166 require( ABSPATH . WPINC . '/class-wp-post.php' );
    167147require( ABSPATH . WPINC . '/post-template.php' );
    168148require( ABSPATH . WPINC . '/revision.php' );
     
    170150require( ABSPATH . WPINC . '/post-thumbnail-template.php' );
    171151require( ABSPATH . WPINC . '/category.php' );
    172 require( ABSPATH . WPINC . '/class-walker-category.php' );
    173 require( ABSPATH . WPINC . '/class-walker-category-dropdown.php' );
    174152require( ABSPATH . WPINC . '/category-template.php' );
    175153require( ABSPATH . WPINC . '/comment.php' );
    176 require( ABSPATH . WPINC . '/class-wp-comment.php' );
    177 require( ABSPATH . WPINC . '/class-wp-comment-query.php' );
    178 require( ABSPATH . WPINC . '/class-walker-comment.php' );
    179154require( ABSPATH . WPINC . '/comment-template.php' );
    180155require( ABSPATH . WPINC . '/rewrite.php' );
    181 require( ABSPATH . WPINC . '/class-wp-rewrite.php' );
    182156require( ABSPATH . WPINC . '/feed.php' );
    183157require( ABSPATH . WPINC . '/bookmark.php' );
     
    188162require( ABSPATH . WPINC . '/script-loader.php' );
    189163require( ABSPATH . WPINC . '/taxonomy.php' );
    190 require( ABSPATH . WPINC . '/class-wp-term.php' );
    191 require( ABSPATH . WPINC . '/class-wp-term-query.php' );
    192 require( ABSPATH . WPINC . '/class-wp-tax-query.php' );
    193164require( ABSPATH . WPINC . '/update.php' );
    194165require( ABSPATH . WPINC . '/canonical.php' );
    195166require( ABSPATH . WPINC . '/shortcodes.php' );
    196167require( ABSPATH . WPINC . '/embed.php' );
    197 require( ABSPATH . WPINC . '/class-wp-embed.php' );
    198 require( ABSPATH . WPINC . '/class-oembed.php' );
    199 require( ABSPATH . WPINC . '/class-wp-oembed-controller.php' );
    200168require( ABSPATH . WPINC . '/media.php' );
    201169require( ABSPATH . WPINC . '/http.php' );
    202 require( ABSPATH . WPINC . '/class-http.php' );
    203 require( ABSPATH . WPINC . '/class-wp-http-streams.php' );
    204 require( ABSPATH . WPINC . '/class-wp-http-curl.php' );
    205 require( ABSPATH . WPINC . '/class-wp-http-proxy.php' );
    206 require( ABSPATH . WPINC . '/class-wp-http-cookie.php' );
    207 require( ABSPATH . WPINC . '/class-wp-http-encoding.php' );
    208 require( ABSPATH . WPINC . '/class-wp-http-response.php' );
    209 require( ABSPATH . WPINC . '/class-wp-http-requests-response.php' );
    210170require( ABSPATH . WPINC . '/widgets.php' );
    211 require( ABSPATH . WPINC . '/class-wp-widget.php' );
    212 require( ABSPATH . WPINC . '/class-wp-widget-factory.php' );
    213171require( ABSPATH . WPINC . '/nav-menu.php' );
    214172require( ABSPATH . WPINC . '/nav-menu-template.php' );
    215173require( ABSPATH . WPINC . '/admin-bar.php' );
    216174require( ABSPATH . WPINC . '/rest-api.php' );
    217 require( ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php' );
    218 require( ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php' );
    219 require( ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php' );
    220 require( ABSPATH . WPINC . '/class-wp-locale.php' );
    221175
    222176$GLOBALS['wp_embed'] = new WP_Embed();
Note: See TracChangeset for help on using the changeset viewer.