Skip to content

Commit

Permalink
fix: php8.3 should allow environment variables to php-fpm (#5573)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Nov 27, 2023
1 parent 7e872a7 commit b396c9d
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 10 deletions.
3 changes: 1 addition & 2 deletions cmd/ddev/cmd/xdebug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ func TestCmdXdebug(t *testing.T) {

// TestDdevXdebugEnabled has already tested enough versions, so limit it here.
// and this is a pretty limited test, doesn't do much but turn on and off
// TODO: Move from PHP81 to PHP82
phpVersions := []string{nodeps.PHP80, nodeps.PHP81}
phpVersions := []string{nodeps.PHP81, nodeps.PHP82}

pwd, _ := os.Getwd()
v := TestSites[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ error_log = /dev/stdout

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes
daemonize = no

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ pm.status_path = /phpstatus
; Note: on highloaded environment, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes
catch_workers_output = yes

; Decorate worker output with prefix and suffix containing information about
; the child that writes to the log and if stdout or stderr is used as well as
Expand All @@ -445,7 +445,7 @@ pm.status_path = /phpstatus
; Setting to "no" will make all environment variables available to PHP code
; via getenv(), $_ENV and $_SERVER.
; Default Value: yes
;clear_env = no
clear_env = no

; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=apcu.so
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; configuration for php igbinary module
; priority=20

; Load igbinary extension
extension=igbinary.so

; Use igbinary as session serializer
;session.serialize_handler=igbinary

; Enable or disable compacting of duplicate strings
; The default is On.
igbinary.compact_strings=On

; Use igbinary as serializer in APC cache (3.1.7 or later)
;apc.serializer=igbinary
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; configuration for php imagick module
extension=imagick.so
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; priority=25
extension=memcached.so
; You need to install php-igbinary package to use igbinary serializer
; and php-msgpack to use msgpack serializer
memcached.serializer=php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; configuration for php msgpack module
; priority=20
extension=msgpack.so
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=redis.so
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=uploadprogress.so
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=xmlrpc.so
2 changes: 1 addition & 1 deletion containers/ddev-webserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Build ddev-php-base from ddev-webserver-base
### ddev-php-base is the basic of ddev-php-prod
### and ddev-webserver-* (For DDEV-Local)
FROM ddev/ddev-php-base:v1.22.5 as ddev-webserver-base
FROM ddev/ddev-php-base:20231126_php8.3_fix as ddev-webserver-base

ENV BACKDROP_DRUSH_VERSION=1.4.0
ENV DEBIAN_FRONTEND=noninteractive
Expand Down
31 changes: 29 additions & 2 deletions pkg/ddevapp/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,28 +955,37 @@ func TestPHPConfig(t *testing.T) {
_ = os.Chdir(origDir)
err = app.Stop(true, false)
assert.NoError(err)
_ = os.Remove(filepath.Join(app.AppRoot, ".ddev", ".env"))
_ = os.Remove(filepath.Join(app.AppRoot, "phpinfo.php"))
})

// Most of the time there's no reason to do all versions of PHP
phpKeys := []string{}
exclusions := []string{"5.6", "7.0", "7.1", "7.2", "7.3", "7.4"}
exclusions := []string{nodeps.PHP56, nodeps.PHP70, nodeps.PHP71, nodeps.PHP72, nodeps.PHP73, nodeps.PHP74, nodeps.PHP80}
for k := range nodeps.ValidPHPVersions {
if os.Getenv("GOTEST_SHORT") != "" && !nodeps.ArrayContainsString(exclusions, k) {
phpKeys = append(phpKeys, k)
}
}
sort.Strings(phpKeys)

err = fileutil.CopyFile(filepath.Join(origDir, "testdata/"+t.Name()+"/.ddev/.env"), filepath.Join(site.Dir, ".ddev/.env"))
require.NoError(t, err)
err = fileutil.CopyFile(filepath.Join(origDir, "testdata/"+t.Name()+"/phpinfo.php"), filepath.Join(site.Dir, "phpinfo.php"))
require.NoError(t, err)

for _, v := range phpKeys {
app.PHPVersion = v
err = app.Start()
require.NoError(t, err)

t.Logf("============= PHP version=%s ================", v)

out, _, err := app.Exec(&ddevapp.ExecOpts{
Cmd: "php --version",
})
require.NoError(t, err)
t.Logf("============= PHP version=%s ================", out)
assert.Contains(out, v)

// Look for problems with serialize_precision,https://github.com/ddev/ddev/issues/5092
out, _, err = app.Exec(&ddevapp.ExecOpts{
Expand All @@ -985,6 +994,24 @@ func TestPHPConfig(t *testing.T) {
require.NoError(t, err)
out = strings.Trim(out, "\n")
require.Equal(t, `float(0.6)`, out)

// Verify that environment variables are available in php-fpm
out, _, err = testcommon.GetLocalHTTPResponse(t, "http://"+app.GetHostname()+"/phpinfo.php")
require.NoError(t, err)
assert.Contains(out, "phpversion="+v)
// Make sure that php-fpm isn't clearing environment variables
assert.Contains(out, "IS_DDEV_PROJECT=true")
// Make sure the .ddev/.env file works
assert.Contains(out, "SOMEENV=someenv-value")

// Remove the PHP83 exception when it has missing extensions
if v != nodeps.PHP83 {
// This list does not contain all expected, as php5.6 is missing some, etc.
expectedExtensions := []string{"apcu", "bcmath", "bz2", "curl", "gd", "imagick", "intl", "ldap", "mbstring", "pgsql", "readline", "soap", "sqlite3", "uploadprogress", "xml", "xmlrpc", "zip"}
for _, e := range expectedExtensions {
assert.Contains(out, fmt.Sprintf(`,%s,`, e))
}
}
}

err = app.Stop(true, false)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddevapp/ddevapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ func TestDdevXdebugEnabled(t *testing.T) {

// Most of the time there's no reason to do all versions of PHP
phpKeys := []string{}
// TODO: Re-enable 8.3 when it's available
// TODO: Enable 8.3 when php8.3-xdebug becomes available
exclusions := []string{"5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.3"}
for k := range nodeps.ValidPHPVersions {
if os.Getenv("GOTEST_SHORT") != "" && !nodeps.ArrayContainsString(exclusions, k) {
Expand Down
1 change: 1 addition & 0 deletions pkg/ddevapp/testdata/TestPHPConfig/.ddev/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOMEENV=someenv-value
6 changes: 6 additions & 0 deletions pkg/ddevapp/testdata/TestPHPConfig/phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

print "phpversion=" . phpversion() . "\n";
print "SOMEENV=" . getenv("SOMEENV"). "\n";
print "IS_DDEV_PROJECT=" . getenv("IS_DDEV_PROJECT"). "\n";
print "loaded_extensions=" . implode(",", get_loaded_extensions()) . "\n";
2 changes: 1 addition & 1 deletion pkg/versionconstants/versionconstants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var AmplitudeAPIKey = ""
var WebImg = "ddev/ddev-webserver"

// WebTag defines the default web image tag
var WebTag = "v1.22.5-rc1" // Note that this can be overridden by make
var WebTag = "20231126_php8.3_fix" // Note that this can be overridden by make

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

0 comments on commit b396c9d

Please sign in to comment.