Skip to content

Commit

Permalink
apache-cgi should respect php overrides, fixes #1556 (#1557)
Browse files Browse the repository at this point in the history
* apache-cgi should respect php overrides, fixes #1556

* Add TestPHPOverrides test
  • Loading branch information
rfay committed May 2, 2019
1 parent baef9b2 commit 41e9954
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions containers/ddev-webserver/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if [ -d /mnt/ddev_config/php ] ; then
if [ -n "$(ls -A /mnt/ddev_config/php/*.ini 2>/dev/null)" ]; then
cp /mnt/ddev_config/php/*.ini /etc/php/${DDEV_PHP_VERSION}/cli/conf.d/
cp /mnt/ddev_config/php/*.ini /etc/php/${DDEV_PHP_VERSION}/fpm/conf.d/
cp /mnt/ddev_config/php/*.ini /etc/php/${DDEV_PHP_VERSION}/apache2/conf.d/
fi
fi

Expand Down
55 changes: 55 additions & 0 deletions pkg/ddevapp/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ddevapp_test
import (
"bufio"
"fmt"
"github.com/drud/ddev/pkg/nodeps"
"github.com/stretchr/testify/require"
"io/ioutil"
"os"
Expand Down Expand Up @@ -610,6 +611,60 @@ func TestConfigOverrideDetection(t *testing.T) {
runTime()
}

// TestPHPOverrides tests to make sure that PHP overrides work in all webservers.
func TestPHPOverrides(t *testing.T) {
assert := asrt.New(t)
app := &DdevApp{}
testDir, _ := os.Getwd()

site := TestSites[0]
switchDir := site.Chdir()
defer switchDir()

runTime := testcommon.TimeTrack(time.Now(), fmt.Sprintf("%s PHPOverrides", site.Name))

// Copy test overrides into the project .ddev directory
err := fileutil.CopyDir(filepath.Join(testDir, "testdata/TestPHPOverrides/.ddev/php"), filepath.Join(site.Dir, ".ddev/php"))
assert.NoError(err)
err = fileutil.CopyFile(filepath.Join(testDir, "testdata/TestPHPOverrides/phpinfo.php"), filepath.Join(site.Dir, site.Docroot, "phpinfo.php"))
assert.NoError(err)

// And when we're done, we have to clean those out again.
defer func() {
_ = os.RemoveAll(filepath.Join(site.Dir, ".ddev/php"))
_ = os.RemoveAll(filepath.Join(site.Dir, "phpinfo.php"))
}()

for _, webserverType := range []string{WebserverNginxFPM, WebserverApacheFPM, WebserverApacheCGI} {
testcommon.ClearDockerEnv()
app.WebserverType = webserverType
err = app.Init(site.Dir)
assert.NoError(err)
_ = app.Stop(true, false)
// nolint: errcheck
defer app.Stop(true, false)
startErr := app.StartAndWaitForSync(2)
if startErr != nil {
logs, _ := GetErrLogsFromApp(app, startErr)
t.Logf("failed app.StartAndWait(): %v", startErr)
t.Fatalf("============== logs from app.StartAndWait() ==============\n%s\n", logs)
}

// On Docker Toolbox, it appearas that the change notification gets to the router
// slower than on other platforms. Give it time to come through.
// Otherwise the SSL cert may not yet have been created
if nodeps.IsDockerToolbox() {
time.Sleep(time.Duration(5) * time.Second)
}

_, _ = testcommon.EnsureLocalHTTPContent(t, "http://"+app.GetHostname()+"/phpinfo.php", `max_input_time</td><td class="v">999`)
err = app.Stop(true, false)
assert.NoError(err)
}

runTime()
}

// TestConfigLoadingOrder verifies that configs load in lexicographical order
// AFTER config.yaml
func TestConfigLoadingOrder(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/ddevapp/testdata/TestPHPOverrides/.ddev/php/my-php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[PHP]
max_input_time = 999
2 changes: 2 additions & 0 deletions pkg/ddevapp/testdata/TestPHPOverrides/phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
phpinfo();
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var DockerComposeFileFormatVersion = "3.6"
var WebImg = "drud/ddev-webserver"

// WebTag defines the default web image tag for drud dev
var WebTag = "20190422_blackfire_io" // Note that this can be overridden by make
var WebTag = "20190420_fix_apache_cgi" // Note that this can be overridden by make

// DBImg defines the default db image used for applications.
var DBImg = "drud/ddev-dbserver"
Expand Down

0 comments on commit 41e9954

Please sign in to comment.