No Code Attached Yet bug
avatar heelc29
heelc29
5 Sep 2023

Steps to reproduce the issue

Are the parameters for Divisor and Probability still necessary after convert plugin to task (#41326) where it is possible to set execution rules?
image

avatar heelc29 heelc29 - open - 5 Sep 2023
avatar joomla-cms-bot joomla-cms-bot - change - 5 Sep 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Sep 2023
avatar richard67
richard67 - comment - 5 Sep 2023

It might depend on the configured session handler, if file or database. I think for file they might still be needed because these parameters are passed to php built in methods, and php handles deletion. For database where Joomla handles deletion they might not be necessary. But I am not really sure, I just remember something like that.

avatar heelc29
heelc29 - comment - 5 Sep 2023

I only found references in the plugin itself

$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());
}

avatar richard67
richard67 - comment - 5 Sep 2023

@heelc29 I found this but don’t have the time to check in detail now:

https://www.php.net/manual/en/function.session-gc.php

$this->getApplication()->getSession()->gc();

avatar heelc29
heelc29 - comment - 6 Sep 2023

If i see it right this function ($this->getApplication()->getSession()->gc()) calls only session_gc in the session framework
https://github.com/joomla-framework/session/blob/95c74bd3c8546b73c49440c426eef734a30ea97b/src/Storage/NativeStorage.php#L134

And the task parameter have nothing to do with the php parameter
https://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability

If I search in the code there is only one result: session.gc_maxlifetime

avatar richard67
richard67 - comment - 6 Sep 2023

@heelc29 From what I can see you are right. It was once implemented in Joomla 3.8.6 in that way so it behaves same as the PHP sessiongc, as far as I understand: #19687 . But the parameters are not really related to those used by PHP, and now as we have a scheduled task I also think it should not need that.

However, I am not really an expert on our session handling. I only took the task to finish the scheduler task plugins for J5 because of the beta 1 with the feature freeze being so close and the author of the PRs having been busy with his regular, daily job. So for me it would be ok if someone else takes that task and fixes that. But it should be tested with real tests, not just by code review, so it needs to write good testing instructions.

avatar heelc29
heelc29 - comment - 6 Sep 2023

I am not really an expert on our session handling

Me neither

avatar HLeithner
HLeithner - comment - 6 Sep 2023

Parameters can be removed, they are only used to not run the garbage collection with each request.

avatar richard67
richard67 - comment - 7 Sep 2023

Parameters can be removed, they are only used to not run the garbage collection with each request.

@HLeithner Can the corresponding language strings be removed, too? Or shall they be deprecated?

avatar HLeithner
HLeithner - comment - 7 Sep 2023

can be removed too since they are new in j5

avatar richard67 richard67 - change - 7 Sep 2023
Labels Added: bug
avatar richard67 richard67 - labeled - 7 Sep 2023
avatar alikon
alikon - comment - 8 Sep 2023

i was thinking at this when i've started to write the pr #41326, but at some point i forgot, i'll do a pr

avatar heelc29 heelc29 - change - 8 Sep 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-09-08 16:10:55
Closed_By heelc29
avatar heelc29 heelc29 - close - 8 Sep 2023

Add a Comment

Login with GitHub to post a comment