Hoping to acquire some feedback. I just updated from 2.7.3 to 3.0.5 and all seemed to go well—manager loads and the site loads. During the upgrade, there was an alert about: The sessions garbage collector does not start! What does this mean, and do I need to change a setting somewhere? Other that than and one ModMore Extra that had strange feedback during the update may need some investigation. So far so good though.
What was the exact output?
There is a warning that always gets displayed on install, even when the settings are all correct.
See also this topic:
Maybe take a look at the size of the table modx_session
from time to time. Only if the size is always increasing and old entries never get deleted, you have to act.
I appreciate the feedback. the session table has 378 rows. Will have to learn more to understand the what and when of this table. Here is the full warning: The sessions garbage collector does not start! The current configuration “session.gc_probability” is set to 0 and “session.gc_divisor” is set to 0.
By default, MODX stores sessions in the database, so misconfiguration of these options can cause the session table to grow in size.
Yes these settings look bad (if you use the default MODX session handling ( → system setting session_handler_class
= MODX\Revolution\modSessionHandler
).
Take a look at this article or maybe this topic to learn more about how to solve the issue.
Did you use the same server (with the same settings) when your site was still on MODX 2? Because the session handling is exactly the same in MODX 2 and MODX 3 and this amount of database entries doesn’t indicate a problem with the garbage collection.
Yes. Same server… same settings—except php version updated to 7.4 I think. Merely upgraded to MODx 3.0.5 and honestly never looked at the tables. After the upgrade I did copy, then deleted all errors in the manager… mainly because a look were a result of version 2 updates, and issues with Extras. This being said… I am now seeing bad link errors pop in a few at a time. That happen to be associated with a button for which the tv link field is blank. I did find a fix that I am going to try out. It’s basically a conditional button where if I have a Photogallery for the page… the is a button to load it. I probably originally did not build it in the best way. I am paying closer attention to the errors now… and looking to give the site an overhaul, and remove components and stray code that are not used. Site was built with Foundation… 4 maybe… cannot remember now. Surprisingly has worked pretty well for a long long time… years! Time for an overhaul. Looking at Tailwind css, but also hesitant to delve into something completely different. One crime at a time so to speak.
I’ve just had this same message when upgrading from 3.0.5 to 3.0.6 - never seen this message before and hosting is my usual hosting. Full message is…
Warning
The sessions garbage collector does not start! The current configuration "session.gc_probability" is set to 0 and "session.gc_divisor" is set to 100.
By default, MODX stores sessions in the database, so misconfiguration of these options can cause the session table to grow in size.
This check (during the installation) was introduced with MODX 3.0.5. So you should have seen the same message when upgrading to MODX 3.0.5 (assuming the settings in php.ini weren’t changed).
Keep an eye on the size of the database table modx_session
. If the number of entries only grows (and old entries are never deleted), then see if you can change the value of the setting session.gc_probability
(in php.ini).
Thank you Harry - does the php.ini need to be in the root of the site or elsewhere please?
php.ini is the configuration file for the PHP service.
It depends on your hosting provider where this file is located, and whether you can directly change its content at all.
(If you go to “Manage” → “Reports” → “System Info” in the MODX manager (/manager/?a=system/info
), there is a “View” link to phpinfo()
that should show the location of the file → “Loaded Configuration File”).
Maybe its also possible on your system to change a PHP setting with a .htaccess
file. Or maybe your hosting provider offers a different method via CPanel or Plesk.
Internal error if I try via htaccess. The php.ini file I put in place has no effect and I can’t get access to the main .ini file so I’m sunk really. Can I create a system setting or a cron job to do this?
Creating a cron job to remove old entries from the modx_session
database table periodically should be possible.
I’ll figure out how to do it and report back
I guess you have to load MODX externally (as described here) and then execute the code from the gc()
function of the session handler.
Something like this might work:
<?php
require_once '/absolute/path/to/core/config/config.inc.php'; // Change this path to the actual location of '.../core/config/config.core.php'
require_once MODX_CORE_PATH . 'vendor/autoload.php';
$modx = new \MODX\Revolution\modX();
$modx->initialize('web');
$gcMaxLifetime = (integer) $modx->getOption('session_gc_maxlifetime'); // read the value of the system setting
$maxtime = time() - $gcMaxLifetime;
$return = $modx->removeCollection(MODX\Revolution\modSession::class, ["{$modx->escape('access')} < {$maxtime}"]); // remove the old rows from the modx_session database table
echo $return; // output count of deleted rows
Thank you Harry - I’ll take some time to digest that