Skip to content
Snippets Groups Projects
Commit e9e7c28f authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3243600 by phenaproxima: ProcessFactory can cause a race condition

parent ff08e719
No related branches found
No related tags found
1 merge request!76Issue #3243600: ProcessFactory can cause a race condition
...@@ -47,28 +47,29 @@ build: ...@@ -47,28 +47,29 @@ build:
# halt-on-fail can be set on the run_tests tasks in order to fail fast. # halt-on-fail can be set on the run_tests tasks in order to fail fast.
# suppress-deprecations is false in order to be alerted to usages of # suppress-deprecations is false in order to be alerted to usages of
# deprecated code. # deprecated code.
run_tests.phpunit: # run_tests.phpunit:
types: 'PHPUnit-Unit' # types: 'PHPUnit-Unit'
testgroups: '--all' # testgroups: '--all'
suppress-deprecations: false # suppress-deprecations: false
halt-on-fail: false # halt-on-fail: false
run_tests.kernel: run_tests.kernel:
types: 'PHPUnit-Kernel' types: 'PHPUnit-Kernel'
testgroups: '--all' testgroups: '--all'
suppress-deprecations: false suppress-deprecations: false
halt-on-fail: false halt-on-fail: falses
run_tests.build: repeat: 100
# Limit concurrency due to disk space concerns. # run_tests.build:
concurrency: 15 # # Limit concurrency due to disk space concerns.
types: 'PHPUnit-Build' # concurrency: 15
testgroups: '--all' # types: 'PHPUnit-Build'
suppress-deprecations: false # testgroups: '--all'
halt-on-fail: false # suppress-deprecations: false
run_tests.functional: # halt-on-fail: false
types: 'PHPUnit-Functional' # run_tests.functional:
testgroups: '--all' # types: 'PHPUnit-Functional'
suppress-deprecations: false # testgroups: '--all'
halt-on-fail: false # suppress-deprecations: false
# halt-on-fail: false
# Functional JavaScript tests require a concurrency of 1 because there is # Functional JavaScript tests require a concurrency of 1 because there is
# only one instance of PhantomJS on the testbot machine. # only one instance of PhantomJS on the testbot machine.
#run_tests.javascript: #run_tests.javascript:
......
...@@ -10,6 +10,9 @@ services: ...@@ -10,6 +10,9 @@ services:
# Basic infrastructure services. # Basic infrastructure services.
package_manager.process_factory: package_manager.process_factory:
class: Drupal\package_manager\ProcessFactory class: Drupal\package_manager\ProcessFactory
arguments:
- '@file_system'
- '@config.factory'
package_manager.file_system: package_manager.file_system:
class: PhpTuf\ComposerStager\Infrastructure\Filesystem\Filesystem class: PhpTuf\ComposerStager\Infrastructure\Filesystem\Filesystem
arguments: arguments:
......
...@@ -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;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment