From e28a5675b7081b22223072e8afa0a2be36c90fe4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 5 May 2023 22:24:59 +0200 Subject: [PATCH 1/4] Fixed binary proxies to return whatever the original binary returns as well, fixes #11416 (#11454) --- src/Composer/Installer/BinaryInstaller.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 827c8178c..ba50fe17f 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -337,8 +337,7 @@ if (PHP_VERSION_ID < 80000) { (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true)) || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) ) { - include("phpvfscomposer://" . $binPathExported); - exit(0); + return include("phpvfscomposer://" . $binPathExported); } } @@ -360,7 +359,7 @@ namespace Composer; $globalsCode $streamProxyCode -include $binPathExported; +return include $binPathExported; PROXY; } From bf5ae27b9364f16655621c8e00ec271b80cd1c48 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 7 May 2023 14:39:25 +0200 Subject: [PATCH 2/4] Fix support for readonly classes as plugins, fixes #11404 --- src/Composer/Plugin/PluginManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index 14eb40211..1387abdfb 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -264,7 +264,7 @@ class PluginManager if ($separatorPos) { $className = substr($class, $separatorPos + 1); } - $code = Preg::replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); + $code = Preg::replace('{^((?:(?:final|readonly)\s+)+(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); $code = strtr($code, [ '__FILE__' => var_export($path, true), '__DIR__' => var_export(dirname($path), true), From 2b58f2c625eeb2b4535b3f29878498dedbc4459e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 7 May 2023 14:48:34 +0200 Subject: [PATCH 3/4] Fix getmypid being required as it is not always available, fixes #11401 --- src/Composer/Console/Application.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 9e585e614..01a2497b7 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -339,7 +339,8 @@ class Application extends BaseApplication // Check system temp folder for usability as it can cause weird runtime issues otherwise Silencer::call(static function () use ($io): void { - $tempfile = sys_get_temp_dir() . '/temp-' . getmypid() . '-' . md5(microtime()); + $pid = function_exists('getmypid') ? getmypid() . '-' : ''; + $tempfile = sys_get_temp_dir() . '/temp-' . $pid . md5(microtime()); if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) === __FILE__) && unlink($tempfile) && !file_exists($tempfile))) { $io->writeError(sprintf('PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini', sys_get_temp_dir())); } From a79eef2949af08dba34daf6e30335eba89380426 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 7 May 2023 14:53:17 +0200 Subject: [PATCH 4/4] Fix class renaming in plugin manager --- src/Composer/Plugin/PluginManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index 1387abdfb..65c83c17b 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -264,7 +264,7 @@ class PluginManager if ($separatorPos) { $className = substr($class, $separatorPos + 1); } - $code = Preg::replace('{^((?:(?:final|readonly)\s+)+(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); + $code = Preg::replace('{^((?:(?:final|readonly)\s+)*(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); $code = strtr($code, [ '__FILE__' => var_export($path, true), '__DIR__' => var_export(dirname($path), true),