updated plugin Jetpack Protect version 3.0.2

This commit is contained in:
2024-10-09 12:44:31 +00:00
committed by Gitium
parent a35dc419bc
commit f970470c59
283 changed files with 6970 additions and 2338 deletions

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore
@ -45,7 +45,7 @@ class Autoloader_Locator {
foreach ( $plugin_paths as $plugin_path ) {
$version = $this->get_autoloader_version( $plugin_path );
if ( ! $this->version_selector->is_version_update_required( $latest_version, $version ) ) {
if ( ! $version || ! $this->version_selector->is_version_update_required( $latest_version, $version ) ) {
continue;
}

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore
@ -85,6 +85,9 @@ class Autoloader {
// Register a shutdown handler to clean up the autoloader.
$hook_manager->add_action( 'shutdown', new Shutdown_Handler( $plugins_handler, $cached_plugins, $was_included_by_autoloader ) );
// Register a plugins_loaded handler to check for conflicting autoloaders.
$hook_manager->add_action( 'plugins_loaded', array( $guard, 'check_for_conflicting_autoloaders' ), 1 );
// phpcs:enable Generic.Commenting.DocComment.MissingShort
}
}

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore
@ -83,4 +83,101 @@ class Latest_Autoloader_Guard {
return false;
}
/**
* Check for conflicting autoloaders.
*
* A common source of strange and confusing problems is when another plugin
* registers a Composer autoloader at a higher priority that us. If enabled,
* check for this problem and warn about it.
*
* Called from the plugins_loaded hook.
*
* @since 3.1.0
* @return void
*/
public function check_for_conflicting_autoloaders() {
if ( ! defined( 'JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS' ) || ! JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS ) {
return;
}
global $jetpack_autoloader_loader;
if ( ! isset( $jetpack_autoloader_loader ) ) {
return;
}
$prefixes = array();
foreach ( ( $jetpack_autoloader_loader->get_class_map() ?? array() ) as $classname => $data ) {
$parts = explode( '\\', trim( $classname, '\\' ) );
array_pop( $parts );
while ( $parts ) {
$prefixes[ implode( '\\', $parts ) . '\\' ] = true;
array_pop( $parts );
}
}
foreach ( ( $jetpack_autoloader_loader->get_psr4_map() ?? array() ) as $prefix => $data ) {
$parts = explode( '\\', trim( $prefix, '\\' ) );
while ( $parts ) {
$prefixes[ implode( '\\', $parts ) . '\\' ] = true;
array_pop( $parts );
}
}
$autoload_chain = spl_autoload_functions();
if ( ! $autoload_chain ) {
return;
}
foreach ( $autoload_chain as $autoloader ) {
// No need to check anything after us.
if ( is_array( $autoloader ) && is_string( $autoloader[0] ) && substr( $autoloader[0], 0, strlen( __NAMESPACE__ ) + 1 ) === __NAMESPACE__ . '\\' ) {
break;
}
// We can check Composer autoloaders easily enough.
if ( is_array( $autoloader ) && $autoloader[0] instanceof \Composer\Autoload\ClassLoader && is_callable( array( $autoloader[0], 'getPrefixesPsr4' ) ) ) {
$composer_autoloader = $autoloader[0];
foreach ( $composer_autoloader->getClassMap() as $classname => $path ) {
if ( $jetpack_autoloader_loader->find_class_file( $classname ) ) {
$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.";
// @todo Remove the is_callable check once we drop support for WP 6.5.
if ( is_callable( 'wp_trigger_error' ) ) {
wp_trigger_error( '', $msg );
} else {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $msg );
}
continue 2;
}
}
foreach ( $composer_autoloader->getPrefixesPsr4() as $prefix => $paths ) {
if ( isset( $prefixes[ $prefix ] ) ) {
$path = array_pop( $paths );
$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.";
// @todo Remove the is_callable check once we drop support for WP 6.5.
if ( is_callable( 'wp_trigger_error' ) ) {
wp_trigger_error( '', $msg );
} else {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $msg );
}
continue 2;
}
}
foreach ( $composer_autoloader->getPrefixes() as $prefix => $paths ) {
if ( isset( $prefixes[ $prefix ] ) ) {
$path = array_pop( $paths );
$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.";
// @todo Remove the is_callable check once we drop support for WP 6.5.
if ( is_callable( 'wp_trigger_error' ) ) {
wp_trigger_error( '', $msg );
} else {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $msg );
}
continue 2;
}
}
}
}
}
}

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore
@ -79,7 +79,7 @@ class PHP_Autoloader {
public static function load_class( $class_name ) {
global $jetpack_autoloader_loader;
if ( ! isset( $jetpack_autoloader_loader ) ) {
return;
return false;
}
$file = $jetpack_autoloader_loader->find_class_file( $class_name );
@ -87,6 +87,24 @@ class PHP_Autoloader {
return false;
}
// A common source of strange and confusing problems is when a vendor
// file is autoloaded before all plugins have had a chance to register
// with the autoloader. Detect that, if a development constant is set.
if ( defined( 'JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS' ) && JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS &&
( strpos( $file, '/vendor/' ) !== false || strpos( $file, '/jetpack_vendor/' ) !== false ) &&
is_callable( 'did_action' ) && ! did_action( 'plugins_loaded' )
) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_wp_debug_backtrace_summary -- This is a debug log message.
$msg = "Jetpack Autoloader: Autoloading `$class_name` before the plugins_loaded hook may cause strange and confusing problems. " . wp_debug_backtrace_summary( '', 1 );
// @todo Remove the is_callable check once we drop support for WP 6.5.
if ( is_callable( 'wp_trigger_error' ) ) {
wp_trigger_error( '', $msg );
} else {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $msg );
}
}
require $file;
return true;
}

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore
@ -57,6 +57,26 @@ class Version_Loader {
$this->filemap = $filemap;
}
/**
* Fetch the classmap.
*
* @since 3.1.0
* @return array<string, array>
*/
public function get_class_map() {
return $this->classmap;
}
/**
* Fetch the psr-4 mappings.
*
* @since 3.1.0
* @return array<string, array>
*/
public function get_psr4_map() {
return $this->psr4_map;
}
/**
* Finds the file path for the given class.
*
@ -66,7 +86,7 @@ class Version_Loader {
*/
public function find_class_file( $class_name ) {
$data = $this->select_newest_file(
isset( $this->classmap[ $class_name ] ) ? $this->classmap[ $class_name ] : null,
$this->classmap[ $class_name ] ?? null,
$this->find_psr4_file( $class_name )
);
if ( ! isset( $data ) ) {

View File

@ -5,7 +5,7 @@
* @package automattic/jetpack-autoloader
*/
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ2_2_0\al3_0_7;
namespace Automattic\Jetpack\Autoloader\jpc4802e05bbcf59fd3b6350e8d3e5482c_protectⓥ3_0_2\al3_1_0;
// phpcs:ignore