From abc4012a42fbdb0ca98e097ba12f542f37b6fce0 Mon Sep 17 00:00:00 2001 From: Deltik Date: Fri, 23 Feb 2018 16:13:56 -0600 Subject: [PATCH] cPanelDeployer will no longer delete all databases Parsing bug deleted all MariaDB users and databases that were not in the active tests list. Now, cPanelDeployer will only delete the MariaDB users and databases that are expired and leave those that are not part of the testing suite alone. --- lib/deployers/cpanel_deployer.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/deployers/cpanel_deployer.php b/lib/deployers/cpanel_deployer.php index a851fa087..2cb6f6924 100644 --- a/lib/deployers/cpanel_deployer.php +++ b/lib/deployers/cpanel_deployer.php @@ -289,11 +289,13 @@ class cPanelDeployer private static function prune_mysql_databases($dbs, $ids, $cPanel) { + $prefix = $cPanel->user."_".self::TEST_PREFIX; foreach ($dbs as $db) { $db = (array) $db; - $offset = strpos($db['db'], self::TEST_PREFIX); - $questionable_db = substr($db['db'], $offset); + if (substr($db['db'], 0, strlen($prefix)) !== $prefix) + continue; + $questionable_db = substr($db['db'], strlen($prefix)); if (!in_array($questionable_db, $ids)) { self::println("Deleting expired MySQL database \"".$db['db']."\"…"); @@ -304,11 +306,13 @@ class cPanelDeployer private static function prune_mysql_users($users, $ids, $cPanel) { + $prefix = $cPanel->user."_".self::TEST_PREFIX; foreach ($users as $user) { $user = (array) $user; - $offset = strpos($user['user'], self::TEST_PREFIX); - $questionable_user = substr($user['user'], $offset); + if (substr($user['user'], 0, strlen($prefix)) !== $prefix) + continue; + $questionable_user = substr($user['user'], strlen($prefix)); if (!in_array($questionable_user, $ids)) { self::println("Deleting expired MySQL user \"".$user['user']."\"…");