Skip to content

Read php.ini from the dependency directory in the sessions extension - #1313

Open
ocean90 wants to merge 1 commit into
cloudfoundry:masterfrom
wearerequired:fix/sessions-php-ini-path
Open

Read php.ini from the dependency directory in the sessions extension#1313
ocean90 wants to merge 1 commit into
cloudfoundry:masterfrom
wearerequired:fix/sessions-php-ini-path

Conversation

@ocean90

@ocean90 ocean90 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Staging fails for any app with a bound Redis or Memcached session service:

Running extension Compile phase
**ERROR** Extension compilation failed: extension sessions compile failed: failed to load PHP config: failed to load php.ini: failed to read config file php/etc/php.ini: open php/etc/php.ini: no such file or directory
Failed to compile droplet: Failed to run all supply scripts: exit status 14

This is the failure reported in #1291.

Cause

NewPHPConfigHelper builds its paths from ctx.BuildDir:

phpIniPath: filepath.Join(ctx.BuildDir, "php", "etc", "php.ini"),

NewContext fills that field from os.Getenv("BUILD_DIR"), which the lifecycle never exports, so it is empty and the helper opens the relative path php/etc/php.ini. createExtensionContext does call ctx.Set("BUILD_DIR", s.Stager.BuildDir()), but Set writes into the Data map and does not reach the struct field. Every other extension reads ctx.GetString("BUILD_DIR") and is unaffected, which is why only the sessions path breaks.

The build directory is also the wrong base. installPHP uses filepath.Join(s.Stager.DepDir(), "php"), and php.ini is written to <deps>/<idx>/php/etc/php.ini. Nothing writes to <build>/php.

Fix

Resolve php.ini and php-fpm.conf from ctx.GetString("DEPS_DIR"), which the supply phase sets to s.Stager.DepDir().

Test

sessions_test.go passed only because it assigned ctx.BuildDir directly, with a comment noting that Set() would not work, and created php/etc under the build directory. That layout does not exist at staging time, so the test could not catch this. It now models the dependency directory. All unit tests pass; src/php/brats fails identically before and after this change, on a DeferCleanup misuse in the vendored bratshelper.

The sessions extension resolves php.ini through PHPConfigHelper, which
builds its paths from ctx.BuildDir. That field is populated in NewContext
from a BUILD_DIR environment variable that the lifecycle never exports, so
it is empty and the helper opens the relative path php/etc/php.ini. Any
app with a bound Redis or Memcached session service therefore fails
staging with:

  Extension compilation failed: extension sessions compile failed: failed
  to load PHP config: failed to load php.ini: failed to read config file
  php/etc/php.ini

The supply phase records the real location under the DEPS_DIR key, and
that is also where PHP is installed: php.ini lives in <deps>/<idx>/php/etc,
never under the build directory.

The unit test passed only because it assigned ctx.BuildDir directly,
bypassing the code path production uses, and laid out php/etc under the
build directory. It now models the dependency directory instead.
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 29, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ocean90 / name: Dominik Schilling (2f6aa04)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant