From 8080cb9d0097207682117fcd1748d9cfb2e62ff8 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Tue, 24 Jun 2025 10:48:44 +0100 Subject: [PATCH 01/11] Issue #463: Fix deprecations with PHP 8.4 --- CHANGELOG.md | 1 + README.md | 3 ++- bee.php | 6 ++---- includes/errors.inc | 12 ++++++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab41a133..c3f98b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ database or client does not support it. - The ability to download specified releases or branches of modules, themes, layout templates or Backdrop itself. - Command to convert database to UTF8MB4. +- Support for PHP 8.4 ### Fixed - Unhandled errors and warnings if commands run outside Backdrop root and/or diff --git a/README.md b/README.md index 51e5cd99..eb72e3b4 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,14 @@ database operations (i.e. `db-export`, `db-import`, `db-drop`, `sql` but NOT ### PHP ![Static Badge](https://img.shields.io/badge/php%20compatibility-555555?logo=php&logoColor=white&style=flat-square) +![Static Badge](https://img.shields.io/badge/8.4-blue?style=flat-square) ![Static Badge](https://img.shields.io/badge/8.3-blue?style=flat-square) ![Static Badge](https://img.shields.io/badge/8.2-blue?style=flat-square) ![Static Badge](https://img.shields.io/badge/8.1-blue?style=flat-square) ![Static Badge](https://img.shields.io/badge/8.0-blue?style=flat-square) ![Static Badge](https://img.shields.io/badge/7.4-blue?style=flat-square) -- Bee is tested and works from `7.4` up to `8.3`. +- Bee is tested and works from `7.4` up to `8.4`. ## Installation diff --git a/bee.php b/bee.php index d3a9001d..a397c555 100755 --- a/bee.php +++ b/bee.php @@ -46,15 +46,13 @@ * The file that the error came from. * @param int $line * The line number the error came from. - * @param array $context - * An array of all variables from where the error was triggered. * * @see https://www.php.net/manual/en/function.set-error-handler.php * @see _backdrop_error_handler() */ -function bee_error_handler($error_level, $message, $filename, $line, array $context = NULL) { +function bee_error_handler($error_level, $message, $filename, $line) { require_once __DIR__ . '/includes/errors.inc'; - _bee_error_handler_real($error_level, $message, $filename, $line, $context); + _bee_error_handler_real($error_level, $message, $filename, $line); } /** diff --git a/includes/errors.inc b/includes/errors.inc index 062353b1..5bc8e8af 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -73,13 +73,11 @@ define('BEE_WATCHDOG_DEPRECATED', 8); * The file that the error came from. * @param int $line * The line number the error came from. - * @param array $context - * An array of all variables from where the error was triggered. * * @see https://www.php.net/manual/en/function.set-error-handler.php * @see _backdrop_error_handler_real() */ -function _bee_error_handler_real($error_level, $message, $filename, $line, array $context = NULL) { +function _bee_error_handler_real($error_level, $message, $filename, $line) { if ($error_level & error_reporting()) { $types = _bee_error_levels(); @@ -194,6 +192,7 @@ function _bee_get_last_caller(array $backtrace) { * * @ingroup bee_logging_severity_levels * @see backdrop_error_levels() + * @see https://github.com/backdrop/backdrop/commit/f823b3a49ffb2e6b280650583fe8d0ccae6796f5#diff-8fb28e6d2a966106560c58c335bc3f025c9e385e1497030a49b47c2638518b83 */ function _bee_error_levels() { $types = array( @@ -208,11 +207,16 @@ function _bee_error_levels() { E_USER_ERROR => array('User error', BEE_WATCHDOG_ERROR), E_USER_WARNING => array('User warning', BEE_WATCHDOG_WARNING), E_USER_NOTICE => array('User notice', BEE_WATCHDOG_NOTICE), - E_STRICT => array('Strict warning', BEE_WATCHDOG_DEBUG), E_RECOVERABLE_ERROR => array('Recoverable fatal error', BEE_WATCHDOG_ERROR), E_DEPRECATED => array('Deprecated function', BEE_WATCHDOG_DEBUG), E_USER_DEPRECATED => array('User deprecated function', BEE_WATCHDOG_DEBUG), ); + // E_STRICT was removed from PHP 8.4 and higher, but still exists in older + // versions. + if (version_compare(PHP_VERSION, '8.4.0') < 0) { + $types[E_STRICT] = array('Strict warning', BEE_WATCHDOG_DEBUG); + } + return $types; } From d7315289038d8452206f92731a40a8baee8179e8 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Tue, 24 Jun 2025 10:59:44 +0100 Subject: [PATCH 02/11] Issue #464: Use 'defaults-extra-file' rather than 'defaults-file' within Bee --- commands/db.bee.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/db.bee.inc b/commands/db.bee.inc index 13938fe6..4ecc9d67 100644 --- a/commands/db.bee.inc +++ b/commands/db.bee.inc @@ -422,7 +422,7 @@ function db_bee_mysql_options(array $db_info, $include_db = TRUE) { // Create an array for the connection string and filename. $options = array(); - $options['connection'] = "--defaults-file=$temp_filename "; + $options['connection'] = "--defaults-extra-file=$temp_filename "; $options['connection'] .= ($include_db) ? rawurldecode($db_info['database']) : ''; $options['filename'] = $temp_filename; From 91e9e46d1cc5ce27efb6f180abdb7be598cc846b Mon Sep 17 00:00:00 2001 From: Martin Price Date: Tue, 24 Jun 2025 11:03:20 +0100 Subject: [PATCH 03/11] Issue #463: Update lando recipe to PHP 8.4 --- .lando.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.lando.yml b/.lando.yml index c3ac6876..5fa07694 100644 --- a/.lando.yml +++ b/.lando.yml @@ -2,7 +2,7 @@ name: bee recipe: backdrop keys: false config: - php: 8.3 + php: 8.4 webroot: backdrop database: mysql # Set Xdebug off by default. We use the tooling below to turn it on as needed. @@ -42,7 +42,7 @@ services: database: healthcheck: mysql --defaults-extra-file=/app/.lando/mysql.cnf --silent --execute "SHOW DATABASES;" multisite: - type: php:8.3 + type: php:8.4 webroot: multisite events: pre-rebuild: From ed91fe389ea63a87c275a2f6f777e75808201da2 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Tue, 24 Jun 2025 11:05:37 +0100 Subject: [PATCH 04/11] Lando: Scanner fail quicker to improve startup speed when http urls fail. Also add SSL to multisite. --- .lando.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.lando.yml b/.lando.yml index 5fa07694..68bb5b34 100644 --- a/.lando.yml +++ b/.lando.yml @@ -11,6 +11,9 @@ config: bee: false services: appserver: + # Allow scanner to fail faster; http paths often fail locally. + scanner: + retry: 5 config: php: .lando/php.ini build_as_root: @@ -44,6 +47,10 @@ services: multisite: type: php:8.4 webroot: multisite + ssl: true + # Allow scanner to fail faster; http paths often fail locally. + scanner: + retry: 5 events: pre-rebuild: # Run clean-up tasks. From 443d85197e65fceb83304287e4b2842191c16c4c Mon Sep 17 00:00:00 2001 From: Martin Price Date: Tue, 24 Jun 2025 11:07:28 +0100 Subject: [PATCH 05/11] Lando: Use mysql and mysqldump clients rather than symlinks to mariadb versions. --- .lando.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.lando.yml b/.lando.yml index 68bb5b34..6858a28c 100644 --- a/.lando.yml +++ b/.lando.yml @@ -24,6 +24,13 @@ services: - rm -rf /var/www/.bee # Remove the symlink if it exists. - rm -f /usr/local/bin/bee + # Ensure that the MySQL client is installed. + - cd /var/www && wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb + - export DEBIAN_FRONTEND=noninteractive && apt update && apt install -y /var/www/mysql-apt-config_0.8.34-1_all.deb + - apt update && apt install -y mysql-client + # Disable column statistics as not supported in this server and will show + # warning on mysqldump. + - echo "[mysqldump]\ncolumn-statistics=0" > /etc/mysql/conf.d/zz-lando.cnf build: # Make symlink for `bee` pointing to this version. - ln -s /app/bee.php /usr/local/bin/bee From 6b63cee461c80ccade85a37dfd39a63087cdf050 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Tue, 24 Jun 2025 11:13:11 +0100 Subject: [PATCH 06/11] Lando: Adjust SQL in setup script to support MySQL 8.0 and above. DB user can no longer be created in the GRANT statement. --- .lando/setup.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.lando/setup.sh b/.lando/setup.sh index b1c6b985..7afbc18b 100755 --- a/.lando/setup.sh +++ b/.lando/setup.sh @@ -22,10 +22,11 @@ set_up() { cd /app # Create databases. - mysql -h database -u root -e "CREATE DATABASE IF NOT EXISTS backdrop; GRANT ALL PRIVILEGES ON backdrop.* TO 'backdrop'@'%' IDENTIFIED by 'backdrop';" - mysql -h database -u root -e "CREATE DATABASE multi_one; GRANT ALL PRIVILEGES ON multi_one.* TO 'backdrop'@'%' IDENTIFIED by 'backdrop';" - mysql -h database -u root -e "CREATE DATABASE multi_two; GRANT ALL PRIVILEGES ON multi_two.* TO 'backdrop'@'%' IDENTIFIED by 'backdrop';" - mysql -h database -u root -e "CREATE DATABASE install_test; GRANT ALL PRIVILEGES ON install_test.* TO 'backdrop'@'%' IDENTIFIED by 'backdrop';" + mysql -h database -u root -e "CREATE USER IF NOT EXISTS 'backdrop'@'%' IDENTIFIED BY 'backdrop';" + mysql -h database -u root -e "CREATE DATABASE IF NOT EXISTS backdrop; GRANT ALL PRIVILEGES ON backdrop.* TO 'backdrop'@'%';" + mysql -h database -u root -e "CREATE DATABASE IF NOT EXISTS multi_one; GRANT ALL PRIVILEGES ON multi_one.* TO 'backdrop'@'%';" + mysql -h database -u root -e "CREATE DATABASE IF NOT EXISTS multi_two; GRANT ALL PRIVILEGES ON multi_two.* TO 'backdrop'@'%';" + mysql -h database -u root -e "CREATE DATABASE IF NOT EXISTS install_test; GRANT ALL PRIVILEGES ON install_test.* TO 'backdrop'@'%';" mysql -h database -u root -e "FLUSH PRIVILEGES;" # Configure Backdrop installation. From 05a452ece2a918623ada4e974d041ac9ab9dc597 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Mon, 7 Jul 2025 09:47:10 +0100 Subject: [PATCH 07/11] WIP - Checking which db executable to call --- commands/db.bee.inc | 34 ++++++++++++++++++++++++++++++++++ includes/filesystem.inc | 11 +++++++++++ 2 files changed, 45 insertions(+) diff --git a/commands/db.bee.inc b/commands/db.bee.inc index 4ecc9d67..04ba1079 100644 --- a/commands/db.bee.inc +++ b/commands/db.bee.inc @@ -545,3 +545,37 @@ function utf8mb4_convert_bee_callback($arguments, $options) { state_set('database_utf8mb4_active', TRUE); bee_message('Database and tables successfully converted.'); } + +/** + * Helper function to determine whether to use MySQL or MariaDB executables. + * @param bool $is_dump + * TRUE if the executable needed is the dump executable (e.g. mysqldump or + * mariadb-dump); FALSE otherwise. Defaults to FALSE. + * + * @return string|FALSE + * The executable name to call or FALSE if neither main executable found. + */ +function db_bee_get_executable_name(bool $is_dump = FALSE) { + // Check the main executable to see if it exists. + exec('which mysql', $mysql_output, $mysql_result); + $mysql = trim($mysql_output); + exec('which mariadb', $mariadb_output, $mariadb_result); + $mariadb = trim($mariadb_output); + // If neither can be found, return FALSE. + if (empty($mysql) && empty($mariadb)) { + return FALSE; + } + // If mysql is found, check if the executable is actually a symlink to + // mariadb. + if (!empty($mysql)) { + $executable_group = is_link($mysql) ? 'mariadb' : 'mysql'; + } + else { + $executable_group = 'mariadb'; + // No mysql executable found so go straight to the mariadb . + switch ($is_dump) { + + } + } + +} diff --git a/includes/filesystem.inc b/includes/filesystem.inc index 924dcdf0..3d95ce23 100644 --- a/includes/filesystem.inc +++ b/includes/filesystem.inc @@ -393,6 +393,17 @@ function bee_copy($source, $destination, $self = TRUE) { function bee_get_executable_path($command) { foreach (explode(":", getenv('PATH')) as $directory) { $candidate = "$directory/$command"; + if (in_array($command, array('mysql', 'mysqldump')) && is_link($candidate)) { + switch ($command) { + case 'mysql': + $command = 'mariadb'; + break; + case 'mysqldump': + $command = 'mariadb-dump'; + break; + } + $candidate = "$directory/$command"; + } if (is_executable($candidate)) { return $candidate; } From ebead282e05707de2dddf70891ec9c35a0b462a8 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Thu, 19 Feb 2026 20:50:54 +0000 Subject: [PATCH 08/11] Remove draft change to db.bee.inc --- commands/db.bee.inc | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/commands/db.bee.inc b/commands/db.bee.inc index 04ba1079..4ecc9d67 100644 --- a/commands/db.bee.inc +++ b/commands/db.bee.inc @@ -545,37 +545,3 @@ function utf8mb4_convert_bee_callback($arguments, $options) { state_set('database_utf8mb4_active', TRUE); bee_message('Database and tables successfully converted.'); } - -/** - * Helper function to determine whether to use MySQL or MariaDB executables. - * @param bool $is_dump - * TRUE if the executable needed is the dump executable (e.g. mysqldump or - * mariadb-dump); FALSE otherwise. Defaults to FALSE. - * - * @return string|FALSE - * The executable name to call or FALSE if neither main executable found. - */ -function db_bee_get_executable_name(bool $is_dump = FALSE) { - // Check the main executable to see if it exists. - exec('which mysql', $mysql_output, $mysql_result); - $mysql = trim($mysql_output); - exec('which mariadb', $mariadb_output, $mariadb_result); - $mariadb = trim($mariadb_output); - // If neither can be found, return FALSE. - if (empty($mysql) && empty($mariadb)) { - return FALSE; - } - // If mysql is found, check if the executable is actually a symlink to - // mariadb. - if (!empty($mysql)) { - $executable_group = is_link($mysql) ? 'mariadb' : 'mysql'; - } - else { - $executable_group = 'mariadb'; - // No mysql executable found so go straight to the mariadb . - switch ($is_dump) { - - } - } - -} From b573e62b613e551927b04f36ad1775829676ecf5 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Thu, 19 Feb 2026 20:51:49 +0000 Subject: [PATCH 09/11] Remove temporary workaround and set database to mysql 8.0 --- .lando.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.lando.yml b/.lando.yml index 6858a28c..09ad9d47 100644 --- a/.lando.yml +++ b/.lando.yml @@ -4,7 +4,7 @@ keys: false config: php: 8.4 webroot: backdrop - database: mysql + database: mysql:8.0 # Set Xdebug off by default. We use the tooling below to turn it on as needed. xdebug: false # Need to disable bee so can use the version in the repo. @@ -24,13 +24,13 @@ services: - rm -rf /var/www/.bee # Remove the symlink if it exists. - rm -f /usr/local/bin/bee - # Ensure that the MySQL client is installed. - - cd /var/www && wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb - - export DEBIAN_FRONTEND=noninteractive && apt update && apt install -y /var/www/mysql-apt-config_0.8.34-1_all.deb - - apt update && apt install -y mysql-client - # Disable column statistics as not supported in this server and will show - # warning on mysqldump. - - echo "[mysqldump]\ncolumn-statistics=0" > /etc/mysql/conf.d/zz-lando.cnf + # # Ensure that the MySQL client is installed. + # - cd /var/www && wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb + # - export DEBIAN_FRONTEND=noninteractive && apt update && apt install -y /var/www/mysql-apt-config_0.8.34-1_all.deb + # - apt update && apt install -y mysql-client + # # Disable column statistics as not supported in this server and will show + # # warning on mysqldump. + # - echo "[mysqldump]\ncolumn-statistics=0" > /etc/mysql/conf.d/zz-lando.cnf build: # Make symlink for `bee` pointing to this version. - ln -s /app/bee.php /usr/local/bin/bee From ddc52eb5ae4bc7a359350956efc5915af891727a Mon Sep 17 00:00:00 2001 From: Martin Price Date: Thu, 19 Feb 2026 21:28:40 +0000 Subject: [PATCH 10/11] Remove workaround from bee_get_executable_path --- includes/filesystem.inc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/includes/filesystem.inc b/includes/filesystem.inc index 3d95ce23..924dcdf0 100644 --- a/includes/filesystem.inc +++ b/includes/filesystem.inc @@ -393,17 +393,6 @@ function bee_copy($source, $destination, $self = TRUE) { function bee_get_executable_path($command) { foreach (explode(":", getenv('PATH')) as $directory) { $candidate = "$directory/$command"; - if (in_array($command, array('mysql', 'mysqldump')) && is_link($candidate)) { - switch ($command) { - case 'mysql': - $command = 'mariadb'; - break; - case 'mysqldump': - $command = 'mariadb-dump'; - break; - } - $candidate = "$directory/$command"; - } if (is_executable($candidate)) { return $candidate; } From c55545c1d2e6bc5b9609090354726a4f61a2bd92 Mon Sep 17 00:00:00 2001 From: Martin Price Date: Mon, 23 Feb 2026 09:21:14 +0000 Subject: [PATCH 11/11] Modify test and lando recipe to support PHP 8.4 and MySQL 8.0 --- .lando.yml | 7 ------- CHANGELOG.md | 2 +- tests/multisite/MultisiteInstallCommandsTest.php | 3 +-- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.lando.yml b/.lando.yml index 09ad9d47..6030f5da 100644 --- a/.lando.yml +++ b/.lando.yml @@ -24,13 +24,6 @@ services: - rm -rf /var/www/.bee # Remove the symlink if it exists. - rm -f /usr/local/bin/bee - # # Ensure that the MySQL client is installed. - # - cd /var/www && wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb - # - export DEBIAN_FRONTEND=noninteractive && apt update && apt install -y /var/www/mysql-apt-config_0.8.34-1_all.deb - # - apt update && apt install -y mysql-client - # # Disable column statistics as not supported in this server and will show - # # warning on mysqldump. - # - echo "[mysqldump]\ncolumn-statistics=0" > /etc/mysql/conf.d/zz-lando.cnf build: # Make symlink for `bee` pointing to this version. - ln -s /app/bee.php /usr/local/bin/bee diff --git a/CHANGELOG.md b/CHANGELOG.md index 30d1be8d..65bbffd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project follows the which is based on the major version of Backdrop CMS with a semantic version system for each contributed module, theme and layout. -## [Unreleased] - 2026-02-18 +## [Unreleased] - 2026-02-23 ### Added - An option for the `db-import` command to allow import from newer MariaDB diff --git a/tests/multisite/MultisiteInstallCommandsTest.php b/tests/multisite/MultisiteInstallCommandsTest.php index 0cc0d9c6..7475bd2e 100644 --- a/tests/multisite/MultisiteInstallCommandsTest.php +++ b/tests/multisite/MultisiteInstallCommandsTest.php @@ -33,9 +33,8 @@ public function test_install_command_works() { $this->assertRegExp('/Database host +database/', (string) $output_after); // Cleanup the install. + exec('bee --site=install_test db-drop -y'); exec('rm -r sites/install_test/files'); exec('cp settings.php sites/install_test'); - exec("mysql -h $bee_test_db_host -u root -e 'DROP DATABASE $bee_test_multisite_install_test_db_name; CREATE DATABASE $bee_test_multisite_install_test_db_name; GRANT ALL PRIVILEGES ON $bee_test_multisite_install_test_db_name.* TO \"backdrop\"@\"%\" IDENTIFIED by \"backdrop\";'"); } - }