Skip to content

Commit af8d839

Browse files
committed
Changes to usage of DrupalFinderComposerRuntime API in ScriptHandler
- Add sanity null-check for $drupalRoot - Restore Path generator for config_sync_directory
1 parent 265c3b1 commit af8d839

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: scripts/composer/ScriptHandler.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
use Composer\Semver\Comparator;
1212
use Drupal\Core\Site\Settings;
1313
use Drupal\Core\Site\SettingsEditor;
14-
use DrupalFinder\DrupalFinder;
1514
use DrupalFinder\DrupalFinderComposerRuntime;
1615
use Symfony\Component\Filesystem\Filesystem;
16+
use Symfony\Component\Filesystem\Path;
1717

1818
class ScriptHandler {
1919

@@ -22,6 +22,15 @@ public static function createRequiredFiles(Event $event) {
2222
$drupalFinder = new DrupalFinderComposerRuntime();
2323
$drupalRoot = $drupalFinder->getDrupalRoot();
2424

25+
// If Drupal root was not found, exit.
26+
if (is_null($drupalRoot)) {
27+
$io = $event->getIO();
28+
$io->writeError(
29+
'<error>Drupal root could not be detected.</error>',
30+
);
31+
exit(1);
32+
}
33+
2534
$dirs = [
2635
'modules',
2736
'profiles',
@@ -43,7 +52,7 @@ public static function createRequiredFiles(Event $event) {
4352
require_once $drupalRoot . '/core/includes/install.inc';
4453
new Settings([]);
4554
$settings['settings']['config_sync_directory'] = (object) [
46-
'value' => '../config/sync',
55+
'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot),
4756
'required' => TRUE,
4857
];
4958
SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings);

0 commit comments

Comments
 (0)