PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | vendor/jetpack-autoloader/class-latest-autoloader-guard.php +80 -1 13.3.3 → 16.3 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ⓥ13_3_1\al3_0_4;
8 +namespace Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ16_3\al6_0_1;
9 9
10 10 // phpcs:ignore
11 11
12 12 /**
@@ -81,6 +81,85 @@
81 81 return true;
82 82 }
83 83
84 84 return false;
85 + }
86 +
87 + /**
88 + * Check for conflicting autoloaders.
89 + *
90 + * A common source of strange and confusing problems is when another plugin
91 + * registers a Composer autoloader at a higher priority that us. If enabled,
92 + * check for this problem and warn about it.
93 + *
94 + * Called from the plugins_loaded hook.
95 + *
96 + * @since 3.1.0
97 + * @return void
98 + */
99 + public function check_for_conflicting_autoloaders() {
100 + if ( ! defined( 'JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS' ) || ! JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS ) {
101 + return;
102 + }
103 +
104 + global $jetpack_autoloader_loader;
105 + if ( ! isset( $jetpack_autoloader_loader ) ) {
106 + return;
107 + }
108 + $prefixes = array();
109 + foreach ( ( $jetpack_autoloader_loader->get_class_map() ?? array() ) as $classname => $data ) {
110 + $parts = explode( '\\', trim( $classname, '\\' ) );
111 + array_pop( $parts );
112 + while ( $parts ) {
113 + $prefixes[ implode( '\\', $parts ) . '\\' ] = true;
114 + array_pop( $parts );
115 + }
116 + }
117 + foreach ( ( $jetpack_autoloader_loader->get_psr4_map() ?? array() ) as $prefix => $data ) {
118 + $parts = explode( '\\', trim( $prefix, '\\' ) );
119 + while ( $parts ) {
120 + $prefixes[ implode( '\\', $parts ) . '\\' ] = true;
121 + array_pop( $parts );
122 + }
123 + }
124 +
125 + $autoload_chain = spl_autoload_functions();
126 + if ( ! $autoload_chain ) {
127 + return;
128 + }
129 +
130 + foreach ( $autoload_chain as $autoloader ) {
131 + // No need to check anything after us.
132 + if ( is_array( $autoloader ) && is_string( $autoloader[0] ) && substr( $autoloader[0], 0, strlen( __NAMESPACE__ ) + 1 ) === __NAMESPACE__ . '\\' ) {
133 + break;
134 + }
135 +
136 + // We can check Composer autoloaders easily enough.
137 + if ( is_array( $autoloader ) && $autoloader[0] instanceof \Composer\Autoload\ClassLoader && is_callable( array( $autoloader[0], 'getPrefixesPsr4' ) ) ) {
138 + $composer_autoloader = $autoloader[0];
139 + foreach ( $composer_autoloader->getClassMap() as $classname => $path ) {
140 + if ( $jetpack_autoloader_loader->find_class_file( $classname ) ) {
141 + $msg = "A Composer autoloader is registered with a higher priority than the Jetpack Autoloader and would also handle some of the classes we handle (e.g. $classname => $path). This may cause strange and confusing problems.";
142 + wp_trigger_error( '', $msg );
143 + continue 2;
144 + }
145 + }
146 + foreach ( $composer_autoloader->getPrefixesPsr4() as $prefix => $paths ) {
147 + if ( isset( $prefixes[ $prefix ] ) ) {
148 + $path = array_pop( $paths );
149 + $msg = "A Composer autoloader is registered with a higher priority than the Jetpack Autoloader and would also handle some of the namespaces we handle (e.g. $prefix => $path). This may cause strange and confusing problems.";
150 + wp_trigger_error( '', $msg );
151 + continue 2;
152 + }
153 + }
154 + foreach ( $composer_autoloader->getPrefixes() as $prefix => $paths ) {
155 + if ( isset( $prefixes[ $prefix ] ) ) {
156 + $path = array_pop( $paths );
157 + $msg = "A Composer autoloader is registered with a higher priority than the Jetpack Autoloader and would also handle some of the namespaces we handle (e.g. $prefix => $path). This may cause strange and confusing problems.";
158 + wp_trigger_error( '', $msg );
159 + continue 2;
160 + }
161 + }
162 + }
163 + }
85 164 }
86 165 }