← All changes
|
vendor/jetpack-autoloader/class-php-autoloader.php
+14
-2
12.2.3
→
16.3-a.1
View file →
| @@ -4,9 +4,9 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack-autoloader |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -namespace Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ12_2_1; | |
| 8 | +namespace Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ16_3_a_1\al6_0_0; | |
| 9 | 9 | |
| 10 | 10 | // phpcs:ignore |
| 11 | 11 | |
| 12 | 12 | /** |
| @@ -78,14 +78,26 @@ | ||
| 78 | 78 | */ |
| 79 | 79 | public static function load_class( $class_name ) { |
| 80 | 80 | global $jetpack_autoloader_loader; |
| 81 | 81 | if ( ! isset( $jetpack_autoloader_loader ) ) { |
| 82 | - return; | |
| 82 | + return false; | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $file = $jetpack_autoloader_loader->find_class_file( $class_name ); |
| 86 | 86 | if ( ! isset( $file ) ) { |
| 87 | 87 | return false; |
| 88 | + } | |
| 89 | + | |
| 90 | + // A common source of strange and confusing problems is when a vendor | |
| 91 | + // file is autoloaded before all plugins have had a chance to register | |
| 92 | + // with the autoloader. Detect that, if a development constant is set. | |
| 93 | + if ( defined( 'JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS' ) && JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS && | |
| 94 | + ( strpos( $file, '/vendor/' ) !== false || strpos( $file, '/jetpack_vendor/' ) !== false ) && | |
| 95 | + is_callable( 'did_action' ) && ! did_action( 'plugins_loaded' ) | |
| 96 | + ) { | |
| 97 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_wp_debug_backtrace_summary -- This is a debug log message. | |
| 98 | + $msg = "Jetpack Autoloader: Autoloading `$class_name` before the plugins_loaded hook may cause strange and confusing problems. " . wp_debug_backtrace_summary( '', 1 ); | |
| 99 | + wp_trigger_error( '', $msg ); | |
| 88 | 100 | } |
| 89 | 101 | |
| 90 | 102 | require $file; |
| 91 | 103 | return true; |