rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -12,9 +12,6 @@
// phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
// phpcs:disable WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_export
// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fopen
// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fwrite
namespace Automattic\Jetpack\Autoloader;

View File

@@ -12,9 +12,6 @@
// phpcs:disable PHPCompatibility.Keywords.NewKeywords.t_dirFound
// phpcs:disable WordPress.Files.FileName.InvalidClassFileName
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_export
// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fopen
// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fwrite
// phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
// phpcs:disable WordPress.NamingConventions.ValidVariableName.InterpolatedVariableNotSnakeCase
@@ -23,7 +20,6 @@
namespace Automattic\Jetpack\Autoloader;
use Composer\Autoload\ClassMapGenerator;
use Composer\Composer;
use Composer\Config;
use Composer\Installer\InstallationManager;
@@ -38,6 +34,13 @@ use Composer\Util\PackageSorter;
*/
class AutoloadGenerator {
/**
* IO object.
*
* @var IOInterface IO object.
*/
private $io;
/**
* The filesystem utility.
*
@@ -302,7 +305,18 @@ class AutoloadGenerator {
$dir = $this->filesystem->normalizePath(
$this->filesystem->isAbsolutePath( $path ) ? $path : $basePath . '/' . $path
);
return ClassMapGenerator::createMap(
// Composer 2.4 changed the name of the class.
if ( class_exists( \Composer\ClassMapGenerator\ClassMapGenerator::class ) ) {
if ( ! is_dir( $dir ) && ! is_file( $dir ) ) {
return array();
}
$generator = new \Composer\ClassMapGenerator\ClassMapGenerator();
$generator->scanPaths( $dir, $excludedClasses, 'classmap', empty( $namespace ) ? null : $namespace );
return $generator->getClassMap()->getMap();
}
return \Composer\Autoload\ClassMapGenerator::createMap(
$dir,
$excludedClasses,
null, // Don't pass the IOInterface since the normal autoload generation will have reported already.

View File

@@ -119,6 +119,8 @@ class AutoloadProcessor {
}
}
ksort( $processed );
return $processed;
}

View File

@@ -123,7 +123,6 @@ class CustomAutoloaderPlugin implements PluginInterface, EventSubscriberInterfac
$generator = new AutoloadGenerator( $this->io );
$generator->dump( $this->composer, $config, $localRepo, $package, $installationManager, 'composer', $optimize, $suffix );
$this->generated = true;
}
/**
@@ -145,7 +144,6 @@ class CustomAutoloaderPlugin implements PluginInterface, EventSubscriberInterfac
// Reuse our own suffix, if any.
if ( is_readable( $vendorPath . '/autoload_packages.php' ) ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$content = file_get_contents( $vendorPath . '/autoload_packages.php' );
if ( preg_match( '/^namespace Automattic\\\\Jetpack\\\\Autoloader\\\\jp([^;\s]+);/m', $content, $match ) ) {
return $match[1];
@@ -154,7 +152,6 @@ class CustomAutoloaderPlugin implements PluginInterface, EventSubscriberInterfac
// Reuse Composer's suffix, if any.
if ( is_readable( $vendorPath . '/autoload.php' ) ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$content = file_get_contents( $vendorPath . '/autoload.php' );
if ( preg_match( '{ComposerAutoloaderInit([^:\s]+)::}', $content, $match ) ) {
return $match[1];

View File

@@ -29,6 +29,9 @@ class PHP_Autoloader {
public function unregister_autoloader() {
// Remove any v2 autoloader that we've already registered.
$autoload_chain = spl_autoload_functions();
if ( ! $autoload_chain ) {
return;
}
foreach ( $autoload_chain as $autoloader ) {
// We can identify a v2 autoloader using the namespace.
$namespace_check = null;

View File

@@ -80,6 +80,7 @@ class Plugin_Locator {
return array();
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated just below.
$action = isset( $_REQUEST['action'] ) ? wp_unslash( $_REQUEST['action'] ) : false;
if ( ! in_array( $action, $allowed_actions, true ) ) {
return array();
@@ -93,6 +94,7 @@ class Plugin_Locator {
break;
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated by convert_plugins_to_paths.
$plugin_slugs[] = wp_unslash( $_REQUEST['plugin'] );
break;
@@ -102,6 +104,7 @@ class Plugin_Locator {
break;
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated by convert_plugins_to_paths.
$plugin_slugs = wp_unslash( $_REQUEST['checked'] );
break;
}

View File

@@ -21,7 +21,7 @@ class Version_Selector {
public function is_version_update_required( $selected_version, $compare_version ) {
$use_dev_versions = defined( 'JETPACK_AUTOLOAD_DEV' ) && JETPACK_AUTOLOAD_DEV;
if ( is_null( $selected_version ) ) {
if ( $selected_version === null ) {
return true;
}