Skip to content

Fix symlink-induced double-load crash in WP Cloud E2E test#148

Merged
adamziel merged 1 commit into
trunkfrom
adamziel/fix-trunk-failures
Apr 17, 2026
Merged

Fix symlink-induced double-load crash in WP Cloud E2E test#148
adamziel merged 1 commit into
trunkfrom
adamziel/fix-trunk-failures

Conversation

@adamziel

Copy link
Copy Markdown
Collaborator

Summary

The import-38-flatten-wpcloud E2E test creates a WP Cloud-like layout where wp-content is a symlink to an external directory. When PHP-FPM serves requests through this layout, utils.php gets loaded twice — once by Composer's files autoload (using the resolved realpath) and once by export.php's require_once (using the symlink path). With the default opcache.revalidate_path=0, PHP doesn't resolve symlinks for require_once deduplication, so the second load triggers Cannot redeclare build_pdo_dsn().

This showed up as a flaky failure on trunk — only PHP 8.1 failed in the latest CI run because the exact symlink resolution behavior varies across PHP versions and opcache states. The same bug would affect any real WP Cloud site where wp-content is symlinked away from ABSPATH.

The fix guards the require_once calls in export.php with function_exists / class_exists checks, so the redundant include is skipped when the Composer autoloader already loaded the files from a different path.

Test plan

  • import-38-flatten-wpcloud passes on all PHP versions in CI (was failing on PHP 8.1)
  • All other E2E tests remain green

When wp-content is a symlink (like in the WP Cloud E2E test layout),
PHP can load utils.php and class-http-server.php twice: once via
Composer's files/classmap autoload (resolved realpath) and once via
export.php's require_once (symlink path). With the default
opcache.revalidate_path=0, require_once doesn't resolve symlinks for
deduplication, so the same physical file gets included from two paths
and function/class declarations collide.

Guard both requires with function_exists/class_exists checks so
the redundant include is skipped regardless of path resolution.
@adamziel
adamziel merged commit afc8318 into trunk Apr 17, 2026
12 checks passed
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