cron.php broken since Joomla 3.8 in some PHP environments
This issue was mentioned in https://issues.civicrm.org/jira/browse/CRM-21203 and the associated PR, which eventually solved problems for cli.php. But there is a session issue that hasn't gone away for cron.php so I am reporting that here.
Depending on PHP error reporting settings (and PHP version possibly, certainly it happens on PHP 7+), this warning will be given:
Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /var/www/html/membership/libraries/joomla/session/handler/joomla.php on line 48
Which may also cause this one:
Warning: session_cache_limiter(): Cannot change cache limiter when headers already sent in /var/www/html/membership/libraries/joomla/session/handler/native.php on line 235
Followed by this error:
Error: Failed to start application: Failed to start the session because headers have already been sent by "/var/www/html/membership/libraries/joomla/session/handler/joomla.php" at line 48.
The cron.php problem started in Joomla 3.8 due to a change that Joomla made to JSessionHandlerJoomla::__construct()
in libraries/joomla/session/handler/joomla.php
.
It could be fixed by Joomla, however I have given up on that. There was an abandoned Joomla PR #15742, superseded by PR #21260, which is also languishing. Anyway we might be better off fixing this on the CiviCRM side.
This is a similar (but separate) case to https://github.com/civicrm/civicrm-core/pull/14074, where extern/rest.php
called session_start()
before bootstrapping the CMS - that issue referred to Drupal though I am sure that it applied to Joomla also (don't know about Wordpress). Removing session_start() was the solution for that REST session problem.