Skip to content
Snippets Groups Projects

mkdir can fail in \Drupal\Core\Test\TestRunnerKernel::boot() because of a race condition

Open Dezső Biczó requested to merge issue/drupal-3190859:3190859-mkdir-can-fail into 9.2.x
1 unresolved thread

Closes #3190859

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
87 87
88 88 // Create the build/artifacts directory if necessary.
89 89 include_once $this->getAppRoot() . '/core/includes/file.inc';
90 if (!is_dir('public://simpletest')) {
91 mkdir('public://simpletest', 0777, TRUE);
90 if (!is_dir('public://simpletest') && !@mkdir('public://simpletest', 0777, TRUE) && !is_dir('public://simpletest')) {
91 throw new \RuntimeException('Unable to create directory: public://simpletest');
  • The only problem with throwing an exception is that the interface Drupal\Core\DrupalKernelInterface::boot() does not document that possibility. Can we add it to the interface.

  • TL;DR; I love to write clean-code and document all possible exceptions that could be thrown and it is useful to know by a developer.

    Although, it is not common practice in Drupal core to document exceptions based on my experiences; and not just in test-related classes. This method can already throw several types of exceptions due to called methods, like Settings, parent:boot(), etc. So I am skeptical about the benefit of adding a @throws to the documentation. Do you think it would be still useful?

  • Please register or sign in to reply
Please register or sign in to reply
Loading