WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/27/2016 09:15:01 AM (3 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-admin/includes/ajax-actions.php

    r38397 r38399  
    15081508    $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
    15091509
    1510     require(ABSPATH . WPINC . '/class-wp-editor.php');
    15111510    $results = _WP_Editors::wp_link_query( $args );
    15121511
     
    31383137function wp_ajax_press_this_save_post() {
    31393138    if ( empty( $GLOBALS['wp_press_this'] ) ) {
    3140         include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
    31413139        $GLOBALS['wp_press_this'] = new WP_Press_This();
    31423140    }
     
    31543152function wp_ajax_press_this_add_category() {
    31553153    if ( empty( $GLOBALS['wp_press_this'] ) ) {
    3156         include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
    31573154        $GLOBALS['wp_press_this'] = new WP_Press_This();
    31583155    }
     
    31843181    switch ( $context ) {
    31853182        case 'site-icon':
    3186             require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php';
    31873183            $wp_site_icon = new WP_Site_Icon();
    31883184
     
    33333329    }
    33343330
    3335     include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    33363331    include_once( ABSPATH . 'wp-admin/includes/theme.php' );
    33373332
     
    34403435    }
    34413436
    3442     include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    3443 
    34443437    $current = get_site_transient( 'update_themes' );
    34453438    if ( empty( $current ) ) {
     
    35913584    }
    35923585
    3593     include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    35943586    include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
    35953587
     
    36993691    }
    37003692
    3701     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    3702 
    37033693    wp_update_plugins();
    37043694
Note: See TracChangeset for help on using the changeset viewer.