wp-browser
wp-browser copied to clipboard
Possible WPLoader dbHost setting Regression in 3.1 [BUG]
Environment OS: Mac PHP version: 7.4 Installed Codeception version: 4.1 Installed wp-browser version: 3.1 WordPress version: 6.0.1 Local development environment: Local by Flywheel WordPress structure and management: default
Codeception configuration file
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
#- tad\WPBrowser\Extension\Symlinker
commands:
- Codeception\Command\GenerateWPUnit
- Codeception\Command\GenerateWPRestApi
- Codeception\Command\GenerateWPRestController
- Codeception\Command\GenerateWPRestPostTypeController
- Codeception\Command\GenerateWPAjax
- Codeception\Command\GenerateWPCanonical
- Codeception\Command\GenerateWPXMLRPC
config:
tad\WPBrowser\Extension\Symlinker:
mode: "theme"
destination: [path-to-theme-dir]
rootFolder:[path-to-theme-dir]
params:
- .env.testing
coverage:
enabled: true
include:
- v1/*
exclude:
- vendor/*
Suite configuration file
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests that require WordPress functions and classes.
actor: WpunitTester
modules:
enabled:
- WPDb
- WPLoader
- \Helper\Wpunit
config:
WPDb:
dsn: "%TEST_SITE_DB_DSN%"
user: "%TEST_SITE_DB_USER%"
password: "%TEST_SITE_DB_PASSWORD%"
dump: "tests/_data/local.sql"
populate: true
cleanup: false
waitlock: 10
url: "%TEST_SITE_WP_URL%"
urlReplacement: false
tablePrefix: "%TEST_SITE_TABLE_PREFIX%"
WPLoader:
loadOnly: true
wpRootFolder: "%WP_ROOT_FOLDER%"
dbName: "%TEST_DB_NAME%"
dbHost: "%TEST_DB_HOST%"
dbUser: "%TEST_DB_USER%"
dbPassword: "%TEST_DB_PASSWORD%"
tablePrefix: "%TEST_TABLE_PREFIX%"
domain: "%TEST_SITE_WP_DOMAIN%"
Describe the bug
With the WPLoader config setting loadOnly: true, the dbHost param is not being set on the wp DB_HOST const.
I'm not 100% sure if this is a bug or the expected behavior, but this setup was working in the previous version of wp-browser (3.0.8). For my setup the dbHost value should be the Local by Flywheel db socket value as I have it set in the "%TEST_DB_HOST%" var. Instead, it is loading the value set in wp-config.php file.
As a workaround, I can set the wp_config.php DB_HOST value to Local's socket path and that seems to be working -- but I'm not sure if that will cause conflicts with Local's own setup or not yet.
Output
mysqli_real_connect(): (HY000/2002): No such file or directory
To Reproduce
Set the WPLoader value for loadOnly to true
Expected behavior The DB_HOST value should be populated
In reviewing the code history in more detail, I believe that this commit is the cause in change of the behavior: https://github.com/lucatume/wp-browser/commit/eeec52112aa2732cb6d6345b6e9bd749d111ec46
The modules look correctly configured.
The only issue I see is the WPDb module acts on the database pointed by TEST_SITE_DB_ env vars, but the WPLoader module acts on the database pointed by TEST_DB_ env vars, likely not finding the database hydrated.
The WPLoader module should not set the DB_HOST constant when in loadOnly: true mode; that is expected behavior.