<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[59309] branches/6.7/tools/local-env: Build/Test Tools: Add MySQL 8.4 support to the Docker environment.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/59309">59309</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/59309","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>desrosj</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-10-28 17:36:17 +0000 (Mon, 28 Oct 2024)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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.
Reviewed by peterwilsoncc.
Merges <a href="https://core.trac.wordpress.org/changeset/59279">[59279]</a> to the 6.7 branch.
Props ayeshrajans, johnbillion, aristath, jorbin.
See <a href="https://core.trac.wordpress.org/ticket/61218">#61218</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches67dockercomposeyml">branches/6.7/docker-compose.yml</a></li>
<li><a href="#branches67toolslocalenvscriptsdockerjs">branches/6.7/tools/local-env/scripts/docker.js</a></li>
<li><a href="#branches67toolslocalenvscriptsinstalljs">branches/6.7/tools/local-env/scripts/install.js</a></li>
<li><a href="#branches67toolslocalenvscriptsstartjs">branches/6.7/tools/local-env/scripts/start.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branches67toolslocalenvmysqloldphpconf">branches/6.7/tools/local-env/mysql-old-php.conf</a></li>
<li><a href="#branches67toolslocalenvoldphpmysql84overrideyml">branches/6.7/tools/local-env/old-php-mysql-84.override.yml</a></li>
<li><a href="#branches67toolslocalenvscriptsutilsjs">branches/6.7/tools/local-env/scripts/utils.js</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#branches67">branches/6.7/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/6.7
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/6.7 2024-10-28 05:04:26 UTC (rev 59308)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/6.7 2024-10-28 17:36:17 UTC (rev 59309)
</ins><a id="branches67"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/6.7</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/5.0:43681-43682,43684-43688,43719-43720,43723,43726-43727,43729-43731,43734-43744,43747,43751-43754,43758,43760-43765,43767-43770,43772,43774-43781,43783,43785,43790-43806,43808-43821,43825,43828,43830-43834,43836-43843,43846-43863,43867-43889,43891-43894,43897-43905,43908-43909,43911-43929,43931-43942,43946-43947,43949-43956,43959-43964,43967-43969,43988,43994,44014,44017,44047,44183,44185,44187-44206,44208-44213,44231-44232,44235,44248,44284,44287-44288
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.5:49373-49379,49381
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.8:51889
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:58570,59286,59289-59290,59293,59307
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:58570,59279,59286,59289-59290,59293,59307
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches67dockercomposeyml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/6.7/docker-compose.yml</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.7/docker-compose.yml 2024-10-28 05:04:26 UTC (rev 59308)
+++ branches/6.7/docker-compose.yml 2024-10-28 17:36:17 UTC (rev 59309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -79,7 +79,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> - mysql:/var/lib/mysql
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> # For compatibility with PHP versions that don't support the caching_sha2_password auth plugin used in MySQL 8.0.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- command: --default-authentication-plugin=mysql_native_password
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ command: ${LOCAL_DB_AUTH_OPTION-}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> healthcheck:
</span><span class="cx" style="display: block; padding: 0 10px"> test: [ "CMD-SHELL", "if [ \"$LOCAL_DB_TYPE\" = \"mariadb\" ]; then mariadb-admin ping -h localhost; else mysqladmin ping -h localhost; fi" ]
</span></span></pre></div>
<a id="branches67toolslocalenvmysqloldphpconffromrev59279trunktoolslocalenvmysqloldphpconf"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: branches/6.7/tools/local-env/mysql-old-php.conf (from rev 59279, trunk/tools/local-env/mysql-old-php.conf)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.7/tools/local-env/mysql-old-php.conf (rev 0)
+++ branches/6.7/tools/local-env/mysql-old-php.conf 2024-10-28 17:36:17 UTC (rev 59309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,20 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+##
+# 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
</ins></span></pre></div>
<a id="branches67toolslocalenvoldphpmysql84overrideymlfromrev59279trunktoolslocalenvoldphpmysql84overrideyml"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: branches/6.7/tools/local-env/old-php-mysql-84.override.yml (from rev 59279, trunk/tools/local-env/old-php-mysql-84.override.yml)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.7/tools/local-env/old-php-mysql-84.override.yml (rev 0)
+++ branches/6.7/tools/local-env/old-php-mysql-84.override.yml 2024-10-28 17:36:17 UTC (rev 59309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,5 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+services:
+
+ mysql:
+ volumes:
+ - ./tools/local-env/mysql-old-php.conf:/etc/mysql/conf.d/config-file.cnf
</ins></span></pre></div>
<a id="branches67toolslocalenvscriptsdockerjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/6.7/tools/local-env/scripts/docker.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.7/tools/local-env/scripts/docker.js 2024-10-28 05:04:26 UTC (rev 59308)
+++ branches/6.7/tools/local-env/scripts/docker.js 2024-10-28 17:36:17 UTC (rev 59309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,8 +1,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> const dotenv = require( 'dotenv' );
</span><span class="cx" style="display: block; padding: 0 10px"> const dotenvExpand = require( 'dotenv-expand' );
</span><span class="cx" style="display: block; padding: 0 10px"> const { execSync } = require( 'child_process' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+const local_env_utils = require( './utils' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> dotenvExpand.expand( dotenv.config() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+const composeFiles = local_env_utils.get_compose_files();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Execute any docker compose command passed to this script.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-execSync( 'docker compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+execSync( 'docker compose ' + composeFiles + ' ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } );
</ins></span></pre></div>
<a id="branches67toolslocalenvscriptsinstalljs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/6.7/tools/local-env/scripts/install.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.7/tools/local-env/scripts/install.js 2024-10-28 05:04:26 UTC (rev 59308)
+++ branches/6.7/tools/local-env/scripts/install.js 2024-10-28 17:36:17 UTC (rev 59309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,9 +3,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> const wait_on = require( 'wait-on' );
</span><span class="cx" style="display: block; padding: 0 10px"> const { execSync } = require( 'child_process' );
</span><span class="cx" style="display: block; padding: 0 10px"> const { renameSync, readFileSync, writeFileSync } = require( 'fs' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+const { utils } = require( './utils.js' );
+const local_env_utils = require( './utils' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> dotenvExpand.expand( dotenv.config() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Determine if a non-default database authentication plugin needs to be used.
+local_env_utils.determine_auth_option();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Create wp-config.php.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cli( 'config create --dbname=wordpress_develop --dbuser=root --dbpass=password --dbhost=mysql --path=/var/www/src --force' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,7 +53,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {string} cmd The WP-CLI command to run.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_cli( cmd ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- execSync( `docker compose run --rm cli ${cmd}`, { stdio: 'inherit' } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const composeFiles = local_env_utils.get_compose_files();
+
+ execSync( `docker compose ${composeFiles} run --rm cli ${cmd}`, { stdio: 'inherit' } );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,7 +63,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function install_wp_importer() {
</span><span class="cx" style="display: block; padding: 0 10px"> const testPluginDirectory = 'tests/phpunit/data/plugins/wordpress-importer';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const composeFiles = local_env_utils.get_compose_files();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- execSync( `docker compose exec -T php rm -rf ${testPluginDirectory}`, { stdio: 'inherit' } );
- execSync( `docker compose exec -T php git clone https://github.com/WordPress/wordpress-importer.git ${testPluginDirectory} --depth=1`, { stdio: 'inherit' } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ execSync( `docker compose ${composeFiles} exec -T php rm -rf ${testPluginDirectory}`, { stdio: 'inherit' } );
+ execSync( `docker compose ${composeFiles} exec -T php git clone https://github.com/WordPress/wordpress-importer.git ${testPluginDirectory} --depth=1`, { stdio: 'inherit' } );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="branches67toolslocalenvscriptsstartjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/6.7/tools/local-env/scripts/start.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.7/tools/local-env/scripts/start.js 2024-10-28 05:04:26 UTC (rev 59308)
+++ branches/6.7/tools/local-env/scripts/start.js 2024-10-28 17:36:17 UTC (rev 59309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> const dotenv = require( 'dotenv' );
</span><span class="cx" style="display: block; padding: 0 10px"> const dotenvExpand = require( 'dotenv-expand' );
</span><span class="cx" style="display: block; padding: 0 10px"> const { execSync } = require( 'child_process' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+const local_env_utils = require( './utils' );
</ins><span class="cx" style="display: block; padding: 0 10px"> const { constants, copyFile } = require( 'node:fs' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Copy the default .env file when one is not present.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,6 +11,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> dotenvExpand.expand( dotenv.config() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+const composeFiles = local_env_utils.get_compose_files();
+
+// Determine if a non-default database authentication plugin needs to be used.
+local_env_utils.determine_auth_option();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Check if the Docker service is running.
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> execSync( 'docker info' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -25,7 +31,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> const containers = ( process.env.LOCAL_PHP_MEMCACHED === 'true' )
</span><span class="cx" style="display: block; padding: 0 10px"> ? 'wordpress-develop memcached'
</span><span class="cx" style="display: block; padding: 0 10px"> : 'wordpress-develop';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-execSync( `docker compose up -d ${containers}`, { stdio: 'inherit' } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+execSync( `docker compose ${composeFiles} up -d ${containers}`, { stdio: 'inherit' } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) {
</span></span></pre></div>
<a id="branches67toolslocalenvscriptsutilsjsfromrev59279trunktoolslocalenvscriptsutilsjs"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: branches/6.7/tools/local-env/scripts/utils.js (from rev 59279, trunk/tools/local-env/scripts/utils.js)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.7/tools/local-env/scripts/utils.js (rev 0)
+++ branches/6.7/tools/local-env/scripts/utils.js 2024-10-28 17:36:17 UTC (rev 59309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,53 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+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;
</ins></span></pre>
</div>
</div>
</body>
</html>