Skip to content

Commit

Permalink
Update WordPress settings management, fixes #756, fixes #1156 (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
alkymst authored and andrewfrench committed Oct 11, 2018
1 parent c9e3cb5 commit c350d63
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 123 deletions.
7 changes: 6 additions & 1 deletion docs/users/cli-usage.md
Expand Up @@ -262,7 +262,12 @@ For **Drupal** and **Backdrop**, DDEV settings are written to a DDEV-managed fil

For **TYPO3**, DDEV settings are written to AdditionalConfiguration.php. If AdditionalConfiguration.php exists and is not managed by DDEV, it will not be modified.

For **Wordpress**, DDEV settings are written to wp-config.php.
For **Wordpress**, DDEV settings are written to a DDEV-managed file, wp-config-ddev.php. The `ddev config` command will attempt to write settings through the following steps:

* Write DDEV settings to wp-config-ddev.php
* If no wp-config.php exists, create one that include wp-config-ddev.php
* If a DDEV-managed wp-config.php exists, create one that includes wp-config.php
* If a user-managed wp-config.php exists, instruct the user on how to modify it to include DDEV settings

How do you know if DDEV manages a settings file? You will see the following comment. Remove the comment and DDEV will not attempt to overwrite it!

Expand Down
2 changes: 1 addition & 1 deletion pkg/ddevapp/apptypes.go
Expand Up @@ -70,7 +70,7 @@ func init() {
settingsCreator: createDrupal8SettingsFile, uploadDir: getDrupalUploadDir, hookDefaultComments: getDrupal8Hooks, apptypeSettingsPaths: setDrupalSiteSettingsPaths, appTypeDetect: isDrupal8App, postImportDBAction: nil, configOverrideAction: nil, postConfigAction: nil, postStartAction: drupal8PostStartAction, importFilesAction: drupalImportFilesAction,
},
"wordpress": {
settingsCreator: createWordpressSettingsFile, uploadDir: getWordpressUploadDir, hookDefaultComments: getWordpressHooks, apptypeSettingsPaths: setWordpressSiteSettingsPaths, appTypeDetect: isWordpressApp, postImportDBAction: wordpressPostImportDBAction, configOverrideAction: nil, postConfigAction: nil, postStartAction: nil, importFilesAction: wordpressImportFilesAction,
settingsCreator: createWordpressSettingsFile, uploadDir: getWordpressUploadDir, hookDefaultComments: getWordpressHooks, apptypeSettingsPaths: setWordpressSiteSettingsPaths, appTypeDetect: isWordpressApp, postImportDBAction: nil, configOverrideAction: nil, postConfigAction: nil, postStartAction: nil, importFilesAction: wordpressImportFilesAction,
},
"typo3": {
settingsCreator: createTypo3SettingsFile, uploadDir: getTypo3UploadDir, hookDefaultComments: getTypo3Hooks, apptypeSettingsPaths: setTypo3SiteSettingsPaths, appTypeDetect: isTypo3App, postImportDBAction: nil, configOverrideAction: typo3ConfigOverrideAction, postConfigAction: nil, postStartAction: nil, importFilesAction: typo3ImportFilesAction,
Expand Down
6 changes: 3 additions & 3 deletions pkg/ddevapp/apptypes_test.go
Expand Up @@ -7,11 +7,12 @@ import (

"bufio"
"fmt"
"strings"

"github.com/drud/ddev/pkg/ddevapp"
"github.com/drud/ddev/pkg/testcommon"
"github.com/drud/ddev/pkg/util"
asrt "github.com/stretchr/testify/assert"
"strings"
)

// TestApptypeDetection does a simple test of various filesystem setups to make
Expand All @@ -23,7 +24,7 @@ func TestApptypeDetection(t *testing.T) {
"drupal6": "misc/ahah.js",
"drupal7": "misc/ajax.js",
"drupal8": "core/scripts/drupal.sh",
"wordpress": "wp-login.php",
"wordpress": "wp-settings.php",
"backdrop": "core/scripts/backdrop.sh",
}

Expand All @@ -46,7 +47,6 @@ func TestApptypeDetection(t *testing.T) {
foundType := app.DetectAppType()
assert.EqualValues(expectedType, foundType)
}

}

// TestPostConfigAction tests that the post-config action is properly applied, but only if the
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddevapp/config_test.go
Expand Up @@ -504,7 +504,7 @@ func TestWriteConfig(t *testing.T) {

out, err = ioutil.ReadFile(filepath.Join(testDir, "config.yaml"))
assert.NoError(err)
assert.Contains(string(out), `- exec: wp search-replace`)
assert.Contains(string(out), `- exec: wp cli version`)

err = os.RemoveAll(testDir)
assert.NoError(err)
Expand Down
1 change: 0 additions & 1 deletion pkg/ddevapp/ddevapp_test.go
Expand Up @@ -542,7 +542,6 @@ func TestDdevImportDB(t *testing.T) {
assert.NoError(err)
assert.True(hasAuthSalt)
}

}

if site.DBTarURL != "" {
Expand Down
5 changes: 3 additions & 2 deletions pkg/ddevapp/settings_test.go
Expand Up @@ -10,13 +10,14 @@ import (

"fmt"

"time"

. "github.com/drud/ddev/pkg/ddevapp"
"github.com/drud/ddev/pkg/dockerutil"
"github.com/drud/ddev/pkg/fileutil"
"github.com/drud/ddev/pkg/testcommon"
asrt "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"time"
)

type settingsLocations struct {
Expand All @@ -41,7 +42,7 @@ func TestWriteSettings(t *testing.T) {
"drupal6": "sites/default/settings.ddev.php",
"drupal7": "sites/default/settings.ddev.php",
"drupal8": "sites/default/settings.ddev.php",
"wordpress": "wp-config.php",
"wordpress": "wp-config-ddev.php",
"typo3": "typo3conf/AdditionalConfiguration.php",
}
dir := testcommon.CreateTmpDir(t.Name())
Expand Down

0 comments on commit c350d63

Please sign in to comment.