mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build/Test Tools: Add MySQL 8.4 support to the Docker environment.
Because `caching_sha2_password` is not supported on PHP 7.2 & 7.3, the local Docker environment has used the `--default-authentication-plugin` system variable to always make use of `mysql_native_password` despite MySQL 8.0 deprecating this auth plugin. However in MySQL 8.4, the `--default-authentication-plugin` option was removed in favor of `--authentication-policy`, and `mysql_native_password` is now disabled by default. `mysql_native_password` has also been removed in MySQL 9.0. This change adds support to the local Docker environment for MySQL 8.4 by adding some helper functions that determine which authentication plugin should be used based on the configured PHP/MySQL versions and automatically making the necessary configuration adjustments. Props ayeshrajans, johnbillion, aristath, jorbin. See #61218. git-svn-id: https://develop.svn.wordpress.org/trunk@59279 602fd350-edb4-49c9-b593-d223f7449a82
- Loading branch information
Showing
7 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## | ||
# The local Docker environment will try to use the database software's default authentication plugin whenever possible. | ||
# | ||
# One exception to this is using PHP 7.2 & 7.3 in combination with MySQL >= 8.0. These versions of PHP lack support for | ||
# MySQL's caching_sha2_password plugin, which was made the new default in MySQL 8.0. | ||
# | ||
# Until MySQL 8.4, this could easily be changed using the --default-authentication-plugin with the old value of | ||
# mysql_native_password. | ||
# | ||
# In MySQL 8.4, the --default-authentication-plugin option was removed in favor of --authentication-policy and | ||
# mysql_native_password was disabled by default. | ||
# | ||
# When mounted to the database container in the local Docker environment, this file turns the old authentication plugin | ||
# back on so that PHP 7.2 & 7.3 can be used in combination with MySQL 8.4. | ||
# | ||
# MySQL 9.0 will remove mysql_native_password. | ||
## | ||
|
||
[mysqld] | ||
mysql-native-password=ON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
|
||
mysql: | ||
volumes: | ||
- ./tools/local-env/mysql-old-php.conf:/etc/mysql/conf.d/config-file.cnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
const dotenv = require( 'dotenv' ); | ||
const dotenvExpand = require( 'dotenv-expand' ); | ||
const { execSync } = require( 'child_process' ); | ||
const local_env_utils = require( './utils' ); | ||
|
||
dotenvExpand.expand( dotenv.config() ); | ||
|
||
const composeFiles = local_env_utils.get_compose_files(); | ||
|
||
// Execute any docker compose command passed to this script. | ||
execSync( 'docker compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } ); | ||
execSync( 'docker compose ' + composeFiles + ' ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const local_env_utils = { | ||
|
||
/** | ||
* Determines which Docker compose files are required to properly configure the local environment given the | ||
* specified PHP version, database type, and database version. | ||
* | ||
* By default, only the standard docker-compose.yml file will be used. | ||
* | ||
* When PHP 7.2 or 7.3 is used in combination with MySQL 8.4, an override file will also be returned to ensure | ||
* that the mysql_native_password plugin authentication plugin is on and available for use. | ||
*/ | ||
get_compose_files: function() { | ||
var composeFiles = '-f docker-compose.yml'; | ||
|
||
if ( process.env.LOCAL_DB_TYPE !== 'mysql' ) { | ||
return composeFiles; | ||
} | ||
|
||
if ( process.env.LOCAL_PHP !== '7.2-fpm' && process.env.LOCAL_PHP !== '7.3-fpm' ) { | ||
return composeFiles; | ||
} | ||
|
||
// PHP 7.2/7.3 in combination with MySQL 8.4 requires additional configuration to function properly. | ||
if ( process.env.LOCAL_DB_VERSION === '8.4' ) { | ||
composeFiles = composeFiles + ' -f tools/local-env/old-php-mysql-84.override.yml'; | ||
} | ||
|
||
return composeFiles; | ||
}, | ||
|
||
/** | ||
* Determines the option to pass for proper authentication plugin configuration given the specified PHP version, | ||
* database type, and database version. | ||
*/ | ||
determine_auth_option: function() { | ||
if ( process.env.LOCAL_DB_TYPE !== 'mysql' ) { | ||
return; | ||
} | ||
|
||
if ( process.env.LOCAL_PHP !== '7.2-fpm' && process.env.LOCAL_PHP !== '7.3-fpm' ) { | ||
return; | ||
} | ||
|
||
// MySQL 8.4 removed --default-authentication-plugin in favor of --authentication-policy. | ||
if ( process.env.LOCAL_DB_VERSION === '8.4' ) { | ||
process.env.LOCAL_DB_AUTH_OPTION = '--authentication-policy=mysql_native_password'; | ||
} else { | ||
process.env.LOCAL_DB_AUTH_OPTION = '--default-authentication-plugin=mysql_native_password'; | ||
} | ||
} | ||
}; | ||
|
||
module.exports = local_env_utils; |