Skip to content
Snippets Groups Projects

Issue #3243600: ProcessFactory can cause a race condition

1 unresolved thread
3 files
+ 51
25
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -2,6 +2,8 @@
@@ -2,6 +2,8 @@
namespace Drupal\package_manager;
namespace Drupal\package_manager;
 
use Drupal\Core\Config\ConfigFactoryInterface;
 
use Drupal\Core\File\FileSystemInterface;
use PhpTuf\ComposerStager\Infrastructure\Process\ProcessFactory as StagerProcessFactory;
use PhpTuf\ComposerStager\Infrastructure\Process\ProcessFactory as StagerProcessFactory;
use PhpTuf\ComposerStager\Infrastructure\Process\ProcessFactoryInterface;
use PhpTuf\ComposerStager\Infrastructure\Process\ProcessFactoryInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Process;
@@ -20,11 +22,32 @@ final class ProcessFactory implements ProcessFactoryInterface {
@@ -20,11 +22,32 @@ final class ProcessFactory implements ProcessFactoryInterface {
*/
*/
private $decorated;
private $decorated;
 
/**
 
* The file system service.
 
*
 
* @var \Drupal\Core\File\FileSystemInterface
 
*/
 
private $fileSystem;
 
 
/**
 
* The config factory service.
 
*
 
* @var \Drupal\Core\Config\ConfigFactoryInterface
 
*/
 
private $configFactory;
 
/**
/**
* Constructs a ProcessFactory object.
* Constructs a ProcessFactory object.
 
*
 
* @param \Drupal\Core\File\FileSystemInterface $file_system
 
* The file system service.
 
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
 
* The config factory service.
*/
*/
public function __construct() {
public function __construct(FileSystemInterface $file_system, ConfigFactoryInterface $config_factory) {
$this->decorated = new StagerProcessFactory();
$this->decorated = new StagerProcessFactory();
 
$this->fileSystem = $file_system;
 
$this->configFactory = $config_factory;
}
}
/**
/**
@@ -65,12 +88,11 @@ final class ProcessFactory implements ProcessFactoryInterface {
@@ -65,12 +88,11 @@ final class ProcessFactory implements ProcessFactoryInterface {
* The path which should be used as COMPOSER_HOME.
* The path which should be used as COMPOSER_HOME.
*/
*/
private function getComposerHomePath(): string {
private function getComposerHomePath(): string {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$home_path = $this->fileSystem->getTempDirectory();
$file_system = \Drupal::service('file_system');
$home_path .= '/automatic_updates_composer_home-';
$home_path = $file_system->getTempDirectory() . '/automatic_updates_composer_home';
$home_path .= $this->configFactory->get('system.site')->get('uuid');
if (!is_dir($home_path)) {
$this->fileSystem->prepareDirectory($home_path, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
mkdir($home_path);
}
return $home_path;
return $home_path;
}
}
Loading