From 4ffb145b610972100a7b8199e8d4faeb51573a77 Mon Sep 17 00:00:00 2001 From: datsepp Date: Thu, 12 Sep 2019 12:58:17 +0200 Subject: [PATCH] Fixes to previous commit. --- .../PatchTester/Controller/ResetController.php | 11 ++++++----- .../com_patchtester/PatchTester/Helper.php | 1 - .../PatchTester/Model/PullModel.php | 17 +++++++++-------- .../install/sql/mysql/install.sql | 4 ++-- .../install/sql/postgresql/install.sql | 2 +- .../install/sql/sqlsrv/install.sql | 4 ++-- .../install/sql/updates/mysql/4.0.0.sql | 4 ++-- .../install/sql/updates/postgresql/4.0.0.sql | 2 +- .../install/sql/updates/sqlsrv/4.0.0.sql | 4 ++-- 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/administrator/components/com_patchtester/PatchTester/Controller/ResetController.php b/administrator/components/com_patchtester/PatchTester/Controller/ResetController.php index 074c35f..ec852f8 100644 --- a/administrator/components/com_patchtester/PatchTester/Controller/ResetController.php +++ b/administrator/components/com_patchtester/PatchTester/Controller/ResetController.php @@ -44,12 +44,12 @@ class ResetController extends AbstractController // Check the applied patches in the database first $appliedPatches = $pullModel->getPatchesDividedInProcs(); - if (count($appliedPatches[0])) + if (count($appliedPatches["git"])) { $revertErrored = false; // Let's try to cleanly revert all applied patches - foreach ($appliedPatches as $patch) + foreach ($appliedPatches["git"] as $patch) { try { @@ -62,16 +62,17 @@ class ResetController extends AbstractController } } - if (count($appliedPatches[1])) + if (count($appliedPatches["ci"])) { + $revertErrored = false; // Let's try to cleanly revert all applied patches with ci - foreach ($appliedPatches as $patch) + foreach ($appliedPatches["ci"] as $patch) { try { - $pullModel->revertWithCIServer($patch->id); + $pullModel->revertWithCIServer($patch->insert_id); } catch (\RuntimeException $e) { diff --git a/administrator/components/com_patchtester/PatchTester/Helper.php b/administrator/components/com_patchtester/PatchTester/Helper.php index df9a2d9..bfdd39e 100644 --- a/administrator/components/com_patchtester/PatchTester/Helper.php +++ b/administrator/components/com_patchtester/PatchTester/Helper.php @@ -82,7 +82,6 @@ abstract class Helper // Set name of the zip archive $options->set('zip.name', 'build.zip'); $options->set('zip.log.name', 'deleted_files.log'); - $options->set('zip.chain.name', 'patch_chain.json'); // Set temp archive for extracting and downloading files $options->set('folder.temp', Factory::getConfig()->get('tmp_path')); diff --git a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php index cb3b832..e449a2e 100644 --- a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php +++ b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php @@ -618,13 +618,13 @@ class PullModel extends AbstractModel $patchChain = $this->getLastChain(); // Allow only reverts in order of the patch chain - if ($patchChain[0]->insert_id != $id) + if ($patchChain->insert_id != $id) { - throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN', $patchChain[0]->pull_id)); + throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN', $patchChain->pull_id)); } else { - $this->removeLastChain($patchChain[0]->insert_id); + $this->removeLastChain($patchChain->insert_id); } // We don't want to restore files from an older version @@ -910,14 +910,15 @@ class PullModel extends AbstractModel $appliedByGit = $db->setQuery( $db->getQuery(true) - ->select('pulls.id, pulls.pull_id') - ->from('#__patchtester_chain chain') - ->leftJoin('#__patchtester_pulls pulls', 'chain.id != pulls.id') - )->loadObject(); + ->select('tests.id, tests.pull_id') + ->from('#__patchtester_tests tests') + ->leftJoin('#__patchtester_chain chain', 'tests.id = chain.insert_id') + ->where('chain.insert_id IS NULL') + )->loadObjectList('pull_id'); $appliedByCI = $this->getPatchChain(); - return [$appliedByGit, $appliedByCI]; + return ["git" => $appliedByGit, "ci" => $appliedByCI]; } /** diff --git a/administrator/components/com_patchtester/install/sql/mysql/install.sql b/administrator/components/com_patchtester/install/sql/mysql/install.sql index a76d520..9113485 100644 --- a/administrator/components/com_patchtester/install/sql/mysql/install.sql +++ b/administrator/components/com_patchtester/install/sql/mysql/install.sql @@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS `#__patchtester_tests` ( CREATE TABLE IF NOT EXISTS `#__patchtester_chain` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `insert_id` int(11) NOT NULL - `pull_id` int(11) NOT NULL + `insert_id` int(11) NOT NULL, + `pull_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/administrator/components/com_patchtester/install/sql/postgresql/install.sql b/administrator/components/com_patchtester/install/sql/postgresql/install.sql index f000ca0..85a2ba9 100644 --- a/administrator/components/com_patchtester/install/sql/postgresql/install.sql +++ b/administrator/components/com_patchtester/install/sql/postgresql/install.sql @@ -23,6 +23,6 @@ CREATE TABLE IF NOT EXISTS "#__patchtester_tests" ( CREATE TABLE IF NOT EXISTS "#__patchtester_chain" ( "id" serial NOT NULL, "insert_id" bigint NOT NULL, - "pull_id" bigint NOT NULL + "pull_id" bigint NOT NULL, PRIMARY KEY (`id`) ); diff --git a/administrator/components/com_patchtester/install/sql/sqlsrv/install.sql b/administrator/components/com_patchtester/install/sql/sqlsrv/install.sql index a6d5998..119b506 100644 --- a/administrator/components/com_patchtester/install/sql/sqlsrv/install.sql +++ b/administrator/components/com_patchtester/install/sql/sqlsrv/install.sql @@ -28,8 +28,8 @@ CREATE TABLE [#__patchtester_tests]( CREATE TABLE [#__patchtester_chain] ( [id] [bigint] IDENTITY(1,1) NOT NULL, - [insert_id] [bigint] NOT NULL - [pull_id] [bigint] NOT NULL + [insert_id] [bigint] NOT NULL, + [pull_id] [bigint] NOT NULL, CONSTRAINT [PK_#__patchtester_chain] PRIMARY KEY CLUSTERED ( [id] ASC diff --git a/administrator/components/com_patchtester/install/sql/updates/mysql/4.0.0.sql b/administrator/components/com_patchtester/install/sql/updates/mysql/4.0.0.sql index a92d4e8..44d1d88 100644 --- a/administrator/components/com_patchtester/install/sql/updates/mysql/4.0.0.sql +++ b/administrator/components/com_patchtester/install/sql/updates/mysql/4.0.0.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS `#__patchtester_chain` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `insert_id` int(11) NOT NULL - `pull_id` int(11) NOT NULL + `insert_id` int(11) NOT NULL, + `pull_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; \ No newline at end of file diff --git a/administrator/components/com_patchtester/install/sql/updates/postgresql/4.0.0.sql b/administrator/components/com_patchtester/install/sql/updates/postgresql/4.0.0.sql index 83a2e6c..fb4458d 100644 --- a/administrator/components/com_patchtester/install/sql/updates/postgresql/4.0.0.sql +++ b/administrator/components/com_patchtester/install/sql/updates/postgresql/4.0.0.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS "#__patchtester_chain" ( "id" serial NOT NULL, "insert_id" bigint NOT NULL, - "pull_id" bigint NOT NULL + "pull_id" bigint NOT NULL, PRIMARY KEY (`id`) ); diff --git a/administrator/components/com_patchtester/install/sql/updates/sqlsrv/4.0.0.sql b/administrator/components/com_patchtester/install/sql/updates/sqlsrv/4.0.0.sql index 35049c7..3c6fac8 100644 --- a/administrator/components/com_patchtester/install/sql/updates/sqlsrv/4.0.0.sql +++ b/administrator/components/com_patchtester/install/sql/updates/sqlsrv/4.0.0.sql @@ -1,7 +1,7 @@ CREATE TABLE [#__patchtester_chain] ( [id] [bigint] IDENTITY(1,1) NOT NULL, - [insert_id] [bigint] NOT NULL - [pull_id] [bigint] NOT NULL + [insert_id] [bigint] NOT NULL, + [pull_id] [bigint] NOT NULL, CONSTRAINT [PK_#__patchtester_chain] PRIMARY KEY CLUSTERED ( [id] ASC