Skip to content

Commit 480da86

Browse files
authored
Fix error during Bedrock installs (#63)
* lock illuminate/container on pre 5.7 * tag create bedrock install feature with issue * update bedrock db prefix handling in .env * update expected format of DB_PREFIX in .env
1 parent 740f1b4 commit 480da86

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"require": {
2727
"php": ">=5.5",
28-
"illuminate/container": "^5.1",
28+
"illuminate/container": ">=5.1 <5.7",
2929
"symfony/filesystem": "^2.7 || ^3 || ^4",
3030
"wp-cli/config-command": "^1 || ^2",
3131
"wp-cli/core-command": "^1 || ^2",

features/valet-new-project-bedrock.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Feature: It can create new installs for Valet-supported WordPress projects.
22

3+
@issue-62
34
Scenario: Create a new Bedrock install.
45
Given an empty directory
56
And a random project name as {PROJECT}
@@ -51,7 +52,7 @@ Feature: It can create new installs for Valet-supported WordPress projects.
5152
When I run `wp valet new {PROJECT} --project=bedrock --in={PATH} --dbprefix=foo`
5253
Then the {PATH}/{PROJECT}/.env file should contain:
5354
"""
54-
DB_PREFIX=foo
55+
DB_PREFIX='foo'
5556
"""
5657
And I run `wp eval 'echo getenv("DB_PREFIX");' --path={PATH}/{PROJECT}/web/wp/`
5758
Then STDOUT should be:

src/Installer/BedrockInstaller.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,22 @@ public function configure()
4242
'database_password',
4343
'database_host',
4444
'http://example.com',
45-
'# DB_PREFIX=wp_'
4645
],
4746
[
4847
$this->props->databaseName(),
4948
$this->props->option('dbuser'),
5049
$this->props->databasePassword(),
5150
$this->props->option('dbhost', 'localhost'),
5251
$this->props->fullUrl(),
53-
sprintf('DB_PREFIX=%s', $this->props->option('dbprefix'))
5452
],
5553
file_get_contents($this->props->fullPath('.env.example'))
5654
);
55+
// DB_PREFIX value is quoted in newer versions, not in older.
56+
$env_contents = preg_replace(
57+
'/# DB_PREFIX=.*/',
58+
sprintf('DB_PREFIX=\'%s\'', $this->props->option('dbprefix')),
59+
$env_contents
60+
);
5761

5862
file_put_contents($this->props->fullPath('.env'), $env_contents);
5963
}

0 commit comments

Comments
 (0)