From 23d66cae33fdba8dec83c7aeea1c06082feac5e1 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Thu, 5 Sep 2024 16:59:41 +0600 Subject: [PATCH 1/6] pkp/pkp-lib#9899 Submodule Update ##touhidurabir/i9899_patch_stable_3_4_0## --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index 63b00c7cc8..b191acdc62 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit 63b00c7cc87f3788efba7e5386b9c6929e1a0807 +Subproject commit b191acdc62e0fbaa84447bc239cb9ef17c6381f1 From 55a0f6f389dfbdb2b4c5c0155f253ce87961e2da Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Fri, 27 Sep 2024 19:24:00 +0600 Subject: [PATCH 2/6] pkp/pkp-lib#9899 added backup/restore for dao and container keys --- .../CompileCounterSubmissionDailyMetricsTest.php | 13 +++++++++++++ ...ounterSubmissionInstitutionDailyMetricsTest.php | 13 +++++++++++++ .../CompileSubmissionGeoDailyMetricsTest.php | 12 ++++++++++++ .../statistics/CompileUniqueInvestigationsTest.php | 11 +++++++++++ .../jobs/statistics/CompileUniqueRequestsTest.php | 11 +++++++++++ .../DeleteUsageStatsTemporaryRecordsTest.php | 14 ++++++++++++++ .../statistics/ProcessUsageStatsLogFileTest.php | 14 ++++++++++++++ 7 files changed, 88 insertions(+) diff --git a/tests/jobs/statistics/CompileCounterSubmissionDailyMetricsTest.php b/tests/jobs/statistics/CompileCounterSubmissionDailyMetricsTest.php index ad6baec2fb..3f40dd182d 100644 --- a/tests/jobs/statistics/CompileCounterSubmissionDailyMetricsTest.php +++ b/tests/jobs/statistics/CompileCounterSubmissionDailyMetricsTest.php @@ -31,6 +31,19 @@ class CompileCounterSubmissionDailyMetricsTest extends PKPTestCase O:56:"APP\jobs\statistics\CompileCounterSubmissionDailyMetrics":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";} END; + /** + * @see PKPTestCase::getMockedDAOs() + */ + protected function getMockedDAOs(): array + { + return [ + ...parent::getMockedDAOs(), + 'TemporaryTotalsDAO', + 'TemporaryItemInvestigationsDAO', + 'TemporaryItemRequestsDAO', + ]; + } + /** * Test job is a proper instance */ diff --git a/tests/jobs/statistics/CompileCounterSubmissionInstitutionDailyMetricsTest.php b/tests/jobs/statistics/CompileCounterSubmissionInstitutionDailyMetricsTest.php index c8ef10c4bb..30cbbfb6bd 100644 --- a/tests/jobs/statistics/CompileCounterSubmissionInstitutionDailyMetricsTest.php +++ b/tests/jobs/statistics/CompileCounterSubmissionInstitutionDailyMetricsTest.php @@ -31,6 +31,19 @@ class CompileCounterSubmissionInstitutionDailyMetricsTest extends PKPTestCase O:67:"APP\jobs\statistics\CompileCounterSubmissionInstitutionDailyMetrics":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";} END; + /** + * @see PKPTestCase::getMockedDAOs() + */ + protected function getMockedDAOs(): array + { + return [ + ...parent::getMockedDAOs(), + 'TemporaryTotalsDAO', + 'TemporaryItemInvestigationsDAO', + 'TemporaryItemRequestsDAO', + ]; + } + /** * Test job is a proper instance */ diff --git a/tests/jobs/statistics/CompileSubmissionGeoDailyMetricsTest.php b/tests/jobs/statistics/CompileSubmissionGeoDailyMetricsTest.php index 16dc6f7674..2c01996b35 100644 --- a/tests/jobs/statistics/CompileSubmissionGeoDailyMetricsTest.php +++ b/tests/jobs/statistics/CompileSubmissionGeoDailyMetricsTest.php @@ -31,6 +31,18 @@ class CompileSubmissionGeoDailyMetricsTest extends PKPTestCase O:52:"APP\jobs\statistics\CompileSubmissionGeoDailyMetrics":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";} END; + /** + * @see PKPTestCase::getMockedDAOs() + */ + protected function getMockedDAOs(): array + { + return [ + ...parent::getMockedDAOs(), + 'TemporaryTotalsDAO', + 'TemporaryItemInvestigationsDAO', + ]; + } + /** * Test job is a proper instance */ diff --git a/tests/jobs/statistics/CompileUniqueInvestigationsTest.php b/tests/jobs/statistics/CompileUniqueInvestigationsTest.php index a5ee31b90a..2f9d5d141f 100644 --- a/tests/jobs/statistics/CompileUniqueInvestigationsTest.php +++ b/tests/jobs/statistics/CompileUniqueInvestigationsTest.php @@ -31,6 +31,17 @@ class CompileUniqueInvestigationsTest extends PKPTestCase O:47:"APP\jobs\statistics\CompileUniqueInvestigations":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";} END; + /** + * @see PKPTestCase::getMockedDAOs() + */ + protected function getMockedDAOs(): array + { + return [ + ...parent::getMockedDAOs(), + 'TemporaryItemInvestigationsDAO', + ]; + } + /** * Test job is a proper instance */ diff --git a/tests/jobs/statistics/CompileUniqueRequestsTest.php b/tests/jobs/statistics/CompileUniqueRequestsTest.php index c24717ae0f..955c5490c2 100644 --- a/tests/jobs/statistics/CompileUniqueRequestsTest.php +++ b/tests/jobs/statistics/CompileUniqueRequestsTest.php @@ -31,6 +31,17 @@ class CompileUniqueRequestsTest extends PKPTestCase O:41:"APP\jobs\statistics\CompileUniqueRequests":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";} END; + /** + * @see PKPTestCase::getMockedDAOs() + */ + protected function getMockedDAOs(): array + { + return [ + ...parent::getMockedDAOs(), + 'TemporaryItemRequestsDAO', + ]; + } + /** * Test job is a proper instance */ diff --git a/tests/jobs/statistics/DeleteUsageStatsTemporaryRecordsTest.php b/tests/jobs/statistics/DeleteUsageStatsTemporaryRecordsTest.php index 90e8201bed..9473820d14 100644 --- a/tests/jobs/statistics/DeleteUsageStatsTemporaryRecordsTest.php +++ b/tests/jobs/statistics/DeleteUsageStatsTemporaryRecordsTest.php @@ -31,6 +31,20 @@ class DeleteUsageStatsTemporaryRecordsTest extends PKPTestCase O:52:"APP\jobs\statistics\DeleteUsageStatsTemporaryRecords":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";} END; + /** + * @see PKPTestCase::getMockedDAOs() + */ + protected function getMockedDAOs(): array + { + return [ + ...parent::getMockedDAOs(), + 'TemporaryTotalsDAO', + 'TemporaryItemInvestigationsDAO', + 'TemporaryItemRequestsDAO', + 'TemporaryInstitutionsDAO', + ]; + } + /** * Test job is a proper instance */ diff --git a/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php b/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php index 67072daf56..28a8f8a711 100644 --- a/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php +++ b/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php @@ -39,6 +39,20 @@ class ProcessUsageStatsLogFileTest extends PKPTestCase */ protected $dummyFileContent = '{"time":"2023-08-07 17:27:11","ip":"228dc4e5b6424e9dad52f21261cb2ab5f4651d9cb426d6fdb3d71d5ab8e2ae83","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko\/20100101 Firefox\/115.0","canonicalUrl":"http:\/\/ojs-stable-3_4_0.test\/index.php\/publicknowledge\/index","assocType":256,"contextId":1,"submissionId":null,"representationId":null,"submissionFileId":null,"fileType":null,"country":null,"region":null,"city":null,"institutionIds":[],"version":"3.4.0.0","issueId":null,"issueGalleyId":null}'; + /** + * @see PKPTestCase::getMockedDAOs() + */ + protected function getMockedDAOs(): array + { + return [ + ...parent::getMockedDAOs(), + 'TemporaryTotalsDAO', + 'TemporaryItemInvestigationsDAO', + 'TemporaryItemRequestsDAO', + 'TemporaryInstitutionsDAO', + ]; + } + /** * Test job is a proper instance */ From 2b0441f7325ca050725d1f0e2360d2e0b3d2e707 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 1 Oct 2024 10:11:19 +0600 Subject: [PATCH 3/6] pkp/pkp-lib#9899 fixed usage stats file create/update issue for tests --- .../ProcessUsageStatsLogFileTest.php | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php b/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php index 28a8f8a711..172d48f11a 100644 --- a/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php +++ b/tests/jobs/statistics/ProcessUsageStatsLogFileTest.php @@ -12,13 +12,14 @@ namespace APP\tests\jobs\statistics; -use APP\jobs\statistics\ProcessUsageStatsLogFile; -use APP\statistics\StatisticsHelper; use Mockery; +use ReflectionClass; use PKP\db\DAORegistry; use PKP\task\FileLoader; +use PKP\file\FileManager; use PKP\tests\PKPTestCase; -use ReflectionClass; +use APP\statistics\StatisticsHelper; +use APP\jobs\statistics\ProcessUsageStatsLogFile; /** * @runTestsInSeparateProcesses @@ -75,6 +76,8 @@ public function testRunSerializedJob(): void // we need to create a dummy file if not existed as to avoid mocking PHP's built in functions $dummyFile = $this->createDummyFileIfNeeded($processUsageStatsLogFileJob, 'loadId'); + $this->createArchiveDirectoryIfRequired(); + $temporaryTotalsDAOMock = Mockery::mock(\APP\statistics\TemporaryTotalsDAO::class) ->makePartial() ->shouldReceive([ @@ -142,10 +145,40 @@ protected function createDummyFileIfNeeded(ProcessUsageStatsLogFile $job, string . DIRECTORY_SEPARATOR; if (!file_exists($filePath . $fileName)) { + + // create the 'FileLoader::FILE_LOADER_PATH_DISPATCH' directory if not exists + if (!file_exists($filePath)) { + $fileManager = new FileManager(); + $fileManager->mkdirtree($filePath); + } + + touch($filePath . $fileName); + file_put_contents($filePath . $fileName, $this->dummyFileContent); return $filePath . $fileName; } return null; } + + /** + * Create the archive path/directory as needed + */ + protected function createArchiveDirectoryIfRequired(): bool + { + $filePath = StatisticsHelper::getUsageStatsDirPath() + . DIRECTORY_SEPARATOR + . FileLoader::FILE_LOADER_PATH_ARCHIVE + . DIRECTORY_SEPARATOR; + + if (file_exists($filePath)) { + return true; + } + + // create the 'FileLoader::FILE_LOADER_PATH_ARCHIVE' directory if not exists + $fileManager = new FileManager(); + $fileManager->mkdirtree($filePath); + + return file_exists($filePath); + } } From d960be34dd2fc6bd8f0dfc06c5720105c8ac8b49 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 1 Oct 2024 10:11:27 +0600 Subject: [PATCH 4/6] pkp/pkp-lib#9899 Submodule Update ##touhidurabir/i9899_patch_stable_3_4_0## --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index b191acdc62..aa3c9dee3b 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit b191acdc62e0fbaa84447bc239cb9ef17c6381f1 +Subproject commit aa3c9dee3bab6fb828b44aaecbfee142baf80266 From c1a1f3521fd0f3af8391e635c7496e038831adfc Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Mon, 21 Oct 2024 13:12:26 +0600 Subject: [PATCH 5/6] pkp/pkp-lib#9899 Submodule Update ##touhidurabir/i9899_patch_stable_3_4_0## --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index aa3c9dee3b..44d8f5692e 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit aa3c9dee3bab6fb828b44aaecbfee142baf80266 +Subproject commit 44d8f5692e3d2e5ff24323d5417ba485db71d14d From c93584d4c27661808b7c1f57891cec184ad8bffb Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Thu, 31 Oct 2024 11:56:56 +0600 Subject: [PATCH 6/6] pkp/pkp-lib#9899 Submodule Update ##touhidurabir/i9899_patch_stable_3_4_0## --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index 44d8f5692e..ae703a5617 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit 44d8f5692e3d2e5ff24323d5417ba485db71d14d +Subproject commit ae703a5617211ac260103424cd9bdc05e15f92c9