Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5] Task parameter SessionGC removal #2986

Closed
jgerman-bot opened this issue Sep 13, 2023 · 0 comments · Fixed by #2990
Closed

[5] Task parameter SessionGC removal #2986

jgerman-bot opened this issue Sep 13, 2023 · 0 comments · Fixed by #2990

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#41685 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php
index 741580b32b993..b2bad0bd593bb 100644
--- a/administrator/components/com_admin/script.php
+++ b/administrator/components/com_admin/script.php
@@ -396,8 +396,6 @@ private function migrateSessionGCPlugin($data)
             'state'  => 1,
             'params' => [
                 'enable_session_gc'          => $params->get('enable_session_gc', 1),
-                'gc_probability'             => $params->get('gc_probability', 1),
-                'gc_divisor'                 => $params->get('gc_divisor', 100),
                 'enable_session_metadata_gc' => $params->get('enable_session_metadata_gc', 1),
             ],
         ];
diff --git a/administrator/language/en-GB/plg_task_sessiongc.ini b/administrator/language/en-GB/plg_task_sessiongc.ini
index 193998cf227a6..0064055c70eb8 100644
--- a/administrator/language/en-GB/plg_task_sessiongc.ini
+++ b/administrator/language/en-GB/plg_task_sessiongc.ini
@@ -5,13 +5,9 @@
 
 PLG_TASK_SESSIONGC="Task - Session Data Purge"
 PLG_TASK_SESSIONGC_DESC="Task Plugin that purges expired data and metadata depending on the session handler set in Global Configuration."
-PLG_TASK_SESSIONGC_ENABLE_SESSION_GC_DESC="When enabled, this plugin will attempt to purge expired data based on the frequency calculated by the probability and divisor."
+PLG_TASK_SESSIONGC_ENABLE_SESSION_GC_DESC="When enabled, this plugin will attempt to purge expired data."
 PLG_TASK_SESSIONGC_ENABLE_SESSION_GC_LABEL="Enable Session Data Cleanup"
 PLG_TASK_SESSIONGC_ENABLE_SESSION_METADATA_GC_DESC="When enabled, this plugin will clean optional session metadata from the database. Note that this operation will not run when the database handler is in use as that data is cleared as part of the Session Data Cleanup operation."
 PLG_TASK_SESSIONGC_ENABLE_SESSION_METADATA_GC_LABEL="Enable Session Metadata Cleanup"
-PLG_TASK_SESSIONGC_GC_DIVISOR_DESC="In combination with the probability field, these two fields are used to determine the frequency of the session data cleanup operation being triggered on a request. The probability is calculated by using probability/divisor, eg 1/100 means there is a 1% chance that the process runs on each request."
-PLG_TASK_SESSIONGC_GC_DIVISOR_LABEL="Divisor"
-PLG_TASK_SESSIONGC_GC_PROBABILITY_DESC="In combination with the divisor field, these two fields are used to determine the frequency of the session data cleanup operation being triggered on a request."
-PLG_TASK_SESSIONGC_GC_PROBABILITY_LABEL="Probability"
 PLG_TASK_SESSIONGC_TITLE="Task - Session Data Purge"
 PLG_TASK_SESSIONGC_XML_DESCRIPTION="Task Plugin that purges expired data and metadata depending on the session handler set in Global Configuration."
diff --git a/installation/sql/mysql/extensions.sql b/installation/sql/mysql/extensions.sql
index 66068e924bdc7..7c29f88f10a13 100644
--- a/installation/sql/mysql/extensions.sql
+++ b/installation/sql/mysql/extensions.sql
@@ -927,7 +927,7 @@ CREATE TABLE IF NOT EXISTS `#__scheduler_tasks` (
 
 INSERT INTO `#__scheduler_tasks` (`id`, `asset_id`, `title`, `type`, `execution_rules`, `cron_rules`, `state`, `last_execution`, `next_execution`, `locked`, `params`, `created`, `created_by`) VALUES
 (1, 97, 'RotateLogs', 'rotation.logs', CONCAT('{"rule-type":"interval-days","interval-days":"30","exec-day":"', DATE_FORMAT(NOW(), '%e'), '","exec-time":"', TIME_FORMAT(NOW(), '%H:00'), '"}'), '{"type":"interval","exp":"P30D"}', 1, NULL, DATE_FORMAT(NOW() + INTERVAL 30 DAY, '%Y-%m-%d %H:00:00'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"logstokeep":1}', NOW(), 42),
-(2, 98, 'SessionGC', 'session.gc', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TIME_FORMAT(NOW(), '%H:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, DATE_FORMAT(NOW() + INTERVAL 24 HOUR, '%Y-%m-%d %H:00:00'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"enable_session_gc":1,"enable_session_metadata_gc":1,"gc_probability":1,"gc_divisor":100}', NOW(), 42),
+(2, 98, 'SessionGC', 'session.gc', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TIME_FORMAT(NOW(), '%H:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, DATE_FORMAT(NOW() + INTERVAL 24 HOUR, '%Y-%m-%d %H:00:00'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"enable_session_gc":1,"enable_session_metadata_gc":1}', NOW(), 42),
 (3, 99, 'UpdateNotification', 'update.notification', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TIME_FORMAT(NOW(), '%H:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, DATE_FORMAT(NOW() + INTERVAL 24 HOUR, '%Y-%m-%d %H:00:00'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"email":"","language_override":""}', NOW(), 42);
 
 -- --------------------------------------------------------
diff --git a/installation/sql/postgresql/extensions.sql b/installation/sql/postgresql/extensions.sql
index 6a6efa2c5886e..44260c10055ca 100644
--- a/installation/sql/postgresql/extensions.sql
+++ b/installation/sql/postgresql/extensions.sql
@@ -891,7 +891,7 @@ CREATE INDEX "#__scheduler_tasks_idx_checked_out" ON "#__scheduler_tasks" ("chec
 
 INSERT INTO "#__scheduler_tasks" ("id", "asset_id", "title", "type", "execution_rules", "cron_rules", "state", "last_execution", "next_execution", "locked", "params", "created", "created_by") VALUES
 (1, 97, 'RotateLogs', 'rotation.logs', CONCAT('{"rule-type":"interval-days","interval-days":"30","exec-day":"', TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 'FMDD'), '","exec-time":"', TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 'HH24:00'), '"}'), '{"type":"interval","exp":"P30D"}', 1, NULL, TO_TIMESTAMP(TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + INTERVAL '30 days', 'YYYY-MM-DD HH24:00:00'), 'YYYY-MM-DD HH24:MI:SS'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"logstokeep":1}', CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 42),
-(2, 98, 'SessionGC', 'session.gc', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 'HH24:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, TO_TIMESTAMP(TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + INTERVAL '24 hours', 'YYYY-MM-DD HH24:00:00'), 'YYYY-MM-DD HH24:MI:SS'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"enable_session_gc":1,"enable_session_metadata_gc":1,"gc_probability":1,"gc_divisor":100}', CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 42),
+(2, 98, 'SessionGC', 'session.gc', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 'HH24:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, TO_TIMESTAMP(TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + INTERVAL '24 hours', 'YYYY-MM-DD HH24:00:00'), 'YYYY-MM-DD HH24:MI:SS'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"enable_session_gc":1,"enable_session_metadata_gc":1}', CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 42),
 (3, 99, 'UpdateNotification', 'update.notification', CONCAT('{"rule-type":"interval-hours","interval-hours":"24","exec-day":"01","exec-time":"', TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 'HH24:00'), '"}'), '{"type":"interval","exp":"PT24H"}', 1, NULL, TO_TIMESTAMP(TO_CHAR(CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + INTERVAL '24 hours', 'YYYY-MM-DD HH24:00:00'), 'YYYY-MM-DD HH24:MI:SS'), NULL, '{"individual_log":false,"log_file":"","notifications":{"success_mail":"0","failure_mail":"1","fatal_failure_mail":"1","orphan_mail":"1"},"email":"","language_override":""}', CURRENT_TIMESTAMP AT TIME ZONE 'UTC', 42);
 
 SELECT setval('#__scheduler_tasks_id_seq', 4, false);
diff --git a/plugins/task/sessiongc/forms/sessionGCForm.xml b/plugins/task/sessiongc/forms/sessionGCForm.xml
index 8e3fe59894a35..63802e408433c 100644
--- a/plugins/task/sessiongc/forms/sessionGCForm.xml
+++ b/plugins/task/sessiongc/forms/sessionGCForm.xml
@@ -27,30 +27,6 @@
 				<option value="0">JNO</option>
 				<option value="1">JYES</option>
 			</field>
-
-			<field
-				name="gc_probability"
-				type="number"
-				label="PLG_TASK_SESSIONGC_GC_PROBABILITY_LABEL"
-				description="PLG_TASK_SESSIONGC_GC_PROBABILITY_DESC"
-				filter="uint"
-				validate="number"
-				min="1"
-				default="1"
-				showon="enable_session_gc:1[OR]enable_session_metadata_gc:1"
-			/>
-
-			<field
-				name="gc_divisor"
-				type="number"
-				label="PLG_TASK_SESSIONGC_GC_DIVISOR_LABEL"
-				description="PLG_TASK_SESSIONGC_GC_DIVISOR_DESC"
-				filter="uint"
-				validate="number"
-				min="1"
-				default="100"
-				showon="enable_session_gc:1[OR]enable_session_metadata_gc:1"
-			/>
 		</fieldset>
 	</fields>
 </form>
diff --git a/plugins/task/sessiongc/src/Extension/SessionGC.php b/plugins/task/sessiongc/src/Extension/SessionGC.php
index 8c7b353871707..956367a4844d1 100644
--- a/plugins/task/sessiongc/src/Extension/SessionGC.php
+++ b/plugins/task/sessiongc/src/Extension/SessionGC.php
@@ -106,27 +106,13 @@ private function sessionGC(ExecuteTaskEvent $event): int
         $enableGC = (int) $event->getArgument('params')->enable_session_gc ?? 1;
 
         if ($enableGC) {
-            $probability = (int) $event->getArgument('params')->gc_probability ?? 1;
-            $divisor     = (int) $event->getArgument('params')->gc_divisor ?? 100;
-
-            $random = $divisor * lcg_value();
-
-            if ($probability > 0 && $random < $probability) {
-                $this->getApplication()->getSession()->gc();
-            }
+            $this->getApplication()->getSession()->gc();
         }
 
         $enableMetadata = (int) $event->getArgument('params')->enable_session_metadata_gc ?? 1;
 
         if ($this->getApplication()->get('session_handler', 'none') !== 'database' && $enableMetadata) {
-            $probability = (int) $event->getArgument('params')->gc_probability ?? 1;
-            $divisor     = (int) $event->getArgument('params')->gc_divisor ?? 100;
-
-            $random = $divisor * lcg_value();
-
-            if ($probability > 0 && $random < $probability) {
-                $this->metadataManager->deletePriorTo(time() - $this->getApplication()->getSession()->getExpire());
-            }
+            $this->metadataManager->deletePriorTo(time() - $this->getApplication()->getSession()->getExpire());
         }
 
         $this->logTask('SessionGC end');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants