diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2021-03-23 07:16:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 07:16:35 +0300 |
commit | 866316494366660e44bdaff5a6694ecdcbadbb9b (patch) | |
tree | b866e87298315acee3f5e25d58511e1bd918e625 | |
parent | b93f640b14e9108e610a1e06854900e24794e311 (diff) |
Allow rearchive_reports_in_past_last_n_months setting value to be an int. (#17368)
* Allow setting value to be an int.
* change default to encourage numeric use
* update expected screenshot
4 files changed, 10 insertions, 8 deletions
diff --git a/config/global.ini.php b/config/global.ini.php index 5a6e4fbbef..e890ee0fc7 100755 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -786,7 +786,7 @@ enable_tracking_failures_notification = 1 ; Controls how many months in the past reports are re-archived for plugins that support ; doing this (such as CustomReports). Set to 0 to disable the feature. Default is 6. -rearchive_reports_in_past_last_n_months = last6 +rearchive_reports_in_past_last_n_months = 6 ; If set to 1, when rearchiving reports in the past we do not rearchive segment data with those reports. Default is 0. rearchive_reports_in_past_exclude_segments = 0 diff --git a/core/Archive/ArchiveInvalidator.php b/core/Archive/ArchiveInvalidator.php index 84db85446e..3e8f84775e 100644 --- a/core/Archive/ArchiveInvalidator.php +++ b/core/Archive/ArchiveInvalidator.php @@ -796,9 +796,11 @@ class ArchiveInvalidator return null; } - $lastNMonthsToInvalidate = (int) substr($lastNMonthsToInvalidate, 4); - if (empty($lastNMonthsToInvalidate)) { - return null; + if (!is_numeric($lastNMonthsToInvalidate)) { + $lastNMonthsToInvalidate = (int)str_replace('last', '', $lastNMonthsToInvalidate); + if (empty($lastNMonthsToInvalidate)) { + return null; + } } return Date::yesterday()->subMonth($lastNMonthsToInvalidate)->setDay(1); diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php index 05eb5d632a..7325ca852e 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php @@ -1525,7 +1525,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $reArchiveList = new ReArchiveList(); $reArchiveList->setAll([]); // clear list since adding segments will add to it - Config::getInstance()->General['rearchive_reports_in_past_last_n_months'] = 'last1'; + Config::getInstance()->General['rearchive_reports_in_past_last_n_months'] = '1'; Config::getInstance()->General['rearchive_reports_in_past_exclude_segments'] = 0; $this->invalidator->scheduleReArchiving(1); @@ -1560,7 +1560,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $reArchiveList = new ReArchiveList(); $reArchiveList->setAll([]); // clear list since adding segments will add to it - Config::getInstance()->General['rearchive_reports_in_past_last_n_months'] = 'last1'; + Config::getInstance()->General['rearchive_reports_in_past_last_n_months'] = 1; Config::getInstance()->General['rearchive_reports_in_past_exclude_segments'] = 1; $this->invalidator->scheduleReArchiving(1); diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png index 8ab23620c0..980cac577f 100644 --- a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png +++ b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aec6c14511c24ca7f0ef23eaa5832e63ae0e4cb753380f162f43d5b1152da8f1 -size 4925000 +oid sha256:d02eea401f098ddce7bdd951df45b4246abb4876c1805f339985b42e7cd1fd12 +size 4924958 |