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

CRM-21203 revisited - Joomla 3.8 extra fixes for cli.php #11609

Merged
merged 1 commit into from Mar 23, 2018

Conversation

Projects
None yet
8 participants
@andrewpthompson
Copy link
Contributor

andrewpthompson commented Jan 30, 2018

Overview

Several Joomla 3.8 users have reported that their scheduled jobs do not run via cron.php or cli.php. The patch for CRM-21203 has not resolved this for them.
See my comment on CRM-21203 for more background.
This patch as it stands only partly resolves the PHP notices/warning/error that stops cron jobs running in some PHP environments.

Before

cli.php will output several notices. In my PHP 7.0 test environment it failed, but on PHP 5.6 it still runs.

PHP Notice:  Constant JPATH_ISWIN already defined in /var/www/html/membership/libraries/import.legacy.php on line 64
PHP Stack trace:
PHP   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
PHP   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
PHP   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
PHP   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
PHP   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
PHP   6. require() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498
PHP   7. define() /var/www/html/membership/libraries/import.legacy.php:64

Notice: Constant JPATH_ISWIN already defined in /var/www/html/membership/libraries/import.legacy.php on line 64

Call Stack:
    0.0001     354480   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
    0.0006     427800   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
    0.0008     427800   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
    0.0996    6545984   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
    0.0996    6545984   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
    0.1247    8313536   6. require('/var/www/html/membership/libraries/import.legacy.php') /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498
    0.1247    8313536   7. define() /var/www/html/membership/libraries/import.legacy.php:64

PHP Notice:  Constant JPATH_ISMAC already defined in /var/www/html/membership/libraries/import.legacy.php on line 65
PHP Stack trace:
PHP   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
PHP   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
PHP   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
PHP   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
PHP   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
PHP   6. require() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498
PHP   7. define() /var/www/html/membership/libraries/import.legacy.php:65

Notice: Constant JPATH_ISMAC already defined in /var/www/html/membership/libraries/import.legacy.php on line 65

Call Stack:
    0.0001     354480   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
    0.0006     427800   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
    0.0008     427800   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
    0.0996    6545984   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
    0.0996    6545984   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
    0.1247    8313536   6. require('/var/www/html/membership/libraries/import.legacy.php') /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498
    0.1252    8313672   7. define() /var/www/html/membership/libraries/import.legacy.php:65

PHP Notice:  Constant JROUTER_MODE_RAW already defined in /var/www/html/membership/libraries/import.legacy.php on line 72
PHP Stack trace:
PHP   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
PHP   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
PHP   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
PHP   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
PHP   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
PHP   6. require() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498

Notice: Constant JROUTER_MODE_RAW already defined in /var/www/html/membership/libraries/import.legacy.php on line 72

Call Stack:
    0.0001     354480   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
    0.0006     427800   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
    0.0008     427800   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
    0.0996    6545984   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
    0.0996    6545984   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
    0.1247    8313536   6. require('/var/www/html/membership/libraries/import.legacy.php') /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498

PHP Notice:  Constant JROUTER_MODE_SEF already defined in /var/www/html/membership/libraries/import.legacy.php on line 79
PHP Stack trace:
PHP   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
PHP   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
PHP   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
PHP   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
PHP   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
PHP   6. require() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498

Notice: Constant JROUTER_MODE_SEF already defined in /var/www/html/membership/libraries/import.legacy.php on line 79

Call Stack:
    0.0001     354480   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
    0.0006     427800   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
    0.0008     427800   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
    0.0996    6545984   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
    0.0996    6545984   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
    0.1247    8313536   6. require('/var/www/html/membership/libraries/import.legacy.php') /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:498

PHP Notice:  Constant JROUTER_MODE_RAW already defined in /var/www/html/membership/libraries/import.php on line 60
PHP Stack trace:
PHP   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
PHP   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
PHP   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
PHP   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
PHP   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
PHP   6. require() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:501

Notice: Constant JROUTER_MODE_RAW already defined in /var/www/html/membership/libraries/import.php on line 60

Call Stack:
    0.0001     354480   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
    0.0006     427800   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
    0.0008     427800   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
    0.0996    6545984   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
    0.0996    6545984   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
    0.1264    8308240   6. require('/var/www/html/membership/libraries/import.php') /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:501

PHP Notice:  Constant JROUTER_MODE_SEF already defined in /var/www/html/membership/libraries/import.php on line 67
PHP Stack trace:
PHP   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
PHP   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
PHP   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
PHP   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
PHP   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
PHP   6. require() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:501

Notice: Constant JROUTER_MODE_SEF already defined in /var/www/html/membership/libraries/import.php on line 67

Call Stack:
    0.0001     354480   1. {main}() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:0
    0.0006     427800   2. civicrm_cli->initialize() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.php:31
    0.0008     427800   3. civicrm_cli->_bootstrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:73
    0.0996    6545984   4. CRM_Utils_System::loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/bin/cli.class.php:258
    0.0996    6545984   5. CRM_Utils_System_Joomla->loadBootStrap() /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php:1454
    0.1264    8308240   6. require('/var/www/html/membership/libraries/import.php') /var/www/html/membership/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Joomla.php:501

Error: Failed to start application: Failed to start the session because headers have already been sent by "/var/www/html/membership/libraries/import.legacy.php" at line 64.

Running cron.php is similar. See my comment on CRM-21203.

After

Running cli.php produces no PHP notices, warnings or errors.
This patch still doesn't resolve cron.php's warning/error so far - not sure what needs to be done to fix that.

Technical Details

Made less of the requires apply to Joomla 3.8. See Joomla 3.8's own cli scripts. They require/import fewer files than CiviCRM's CRM_Utils_System_Joomla::loadBootStrap does. For example, Joomla's cli/garbagecron.php will load only includes/defines.php, libraries/import.legacy.php and libraries/cms.php. And cli/finder_indexer.php loads those plus configuration.php.

Comments

Help needed please. We still need to find a solution for cron.php, which will still produce a warning and an error (depending on PHP version & environment):

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
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.

Otherwise it works for my scheduled jobs but I'm not certain if there will be other consequences from removing the includes so assistance is needed with testing.

@civicrm-builder

This comment has been minimized.

Copy link

civicrm-builder commented Jan 30, 2018

Can one of the admins verify this patch?

@mattwire

This comment has been minimized.

Copy link
Contributor

mattwire commented Jan 30, 2018

Jenkins add to whitelist

1 similar comment
@seamuslee001

This comment has been minimized.

Copy link
Contributor

seamuslee001 commented Jan 30, 2018

Jenkins add to whitelist

@mattwire

This comment has been minimized.

Copy link
Contributor

mattwire commented Jan 30, 2018

@lcdservices Tagging you as a Joomla user :-) Let me know if you get chance to comment on this patch

@andrewpthompson

This comment has been minimized.

Copy link
Contributor

andrewpthompson commented Feb 21, 2018

A bit more to add. This is regarding the warning & error that still remain, namely:

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
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.

In CRM_Core_Session::initialize() we do a session_start() for all CMS other than Drupal. This occurs before this line: JPluginHelper::importPlugin('civicrm'); in CRM_Utils_Hook_Joomla::invokeViaUF and it is this that leads to Joomla trying to do an ini_set() when there is a session active.

This applies to cron.php but not cli.php because in the CLI environment this condition stops the session_start:
if (!isset($_SESSION) && PHP_SAPI !== 'cli') {

I found that either of the following will stop the warning & error and let cron.php run normally:

  • Removing session_start() from CRM_Core_Session::initialize()
  • Inserting error_reporting(0) immediately before JPluginHelper::importPlugin('civicrm'); in CRM_Utils_Hook_Joomla::invokeViaUF and restoring error_reporting immediately afterwards.

Question: is it correct for CiviCRM to be doing a PHP session_start() in CRM_Core_Session::initialize() given that Joomla creates its own session? Any ideas?

@thoni56

This comment has been minimized.

Copy link

thoni56 commented Feb 21, 2018

In my development environment (MacOS) this PR fixed the Notices and Errors I had after (test-) upgrading from 4.7.23 to 4.7.30:

Notice: Constant JPATH_ISWIN already defined in /Library/WebServer/Documents/events/libraries/import.legacy.php on line 64
Notice: Constant JPATH_ISMAC already defined in /Library/WebServer/Documents/events/libraries/import.legacy.php on line 65
Notice: Constant JROUTER_MODE_RAW already defined in /Library/WebServer/Documents/events/libraries/import.legacy.php on line 72
Notice: Constant JROUTER_MODE_SEF already defined in /Library/WebServer/Documents/events/libraries/import.legacy.php on line 79
Notice: Constant JROUTER_MODE_RAW already defined in /Library/WebServer/Documents/events/libraries/import.php on line 60
Notice: Constant JROUTER_MODE_SEF already defined in /Library/WebServer/Documents/events/libraries/import.php on line 67
Error: Failed to start application: Failed to start the session because headers have already been sent by "/Library/WebServer/Documents/events/libraries/import.legacy.php" at line 64.`

So should I upgrade my production system and add this patch, or will that come back and haunt me when I upgrade to 4.7.31? ;-)

@mattwire

This comment has been minimized.

Copy link
Contributor

mattwire commented Feb 21, 2018

@thoni56 Did it fix both cron.php and cli.php? Did you remove session_start() or similar as per @andrewpthompson comment?

@thoni56

This comment has been minimized.

Copy link

thoni56 commented Feb 21, 2018

I only tried it with cli.php as that is what we use. I'll test it with cron.php too. NB I ran the command from a terminal, not actually through cron.

I only applied the patch, nothing else.

@thoni56

This comment has been minimized.

Copy link

thoni56 commented Feb 21, 2018

No, it didn't solve the cron.php case:

wget -O - -q -t 1 'http://<site>/events/administrator/components/com_civicrm/civicrm/bin/cron.php?name=<user>&pass=<password>&key=<key>'
<br />
<b>Warning</b>:  ini_set(): A session is active. You cannot change the session module's ini settings at this time in <b>/Library/WebServer/Documents/events/libraries/joomla/session/handler/joomla.php</b> on line <b>48</b><br />
Error: Failed to start application: Failed to start the session because headers have already been sent by "/Library/WebServer/Documents/events/libraries/joomla/session/handler/joomla.php" at line 48.

But removing "session_start()" from line 127 in CRM/Core/Session.php did the trick for cron.php.

@andrewpthompson

This comment has been minimized.

Copy link
Contributor

andrewpthompson commented Feb 22, 2018

I also found that essentially the same problem as cron.php also occurs with REST.

( ! ) Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /var/www/html/testsite/libraries/joomla/session/handler/joomla.php on line 48
Call Stack
#	Time	Memory	Function	Location
1	0.0007	363736	{main}( )	.../rest.php:0
2	0.0479	1481080	CRM_Utils_REST->bootAndRun( )	.../rest.php:42
3	0.0479	1481080	CRM_Utils_REST->loadCMSBootstrap( )	.../REST.php:112
4	0.1287	3939912	CRM_Utils_System::loadBootStrap( )	.../REST.php:621
5	0.1287	3939912	CRM_Utils_System_Joomla->loadBootStrap( )	.../System.php:1462
6	0.1319	4494488	CRM_Utils_Hook::config( )	.../Joomla.php:594
7	0.1320	4494488	CRM_Utils_Hook_Joomla->invoke( )	.../Hook.php:1164
8	0.1320	4495480	Civi\Core\CiviEventDispatcher->dispatch( )	.../Hook.php:164
9	0.1320	4495480	Civi\Core\CiviEventDispatcher->dispatch( )	.../CiviEventDispatcher.php:47
10	0.1320	4495480	Civi\Core\CiviEventDispatcher->dispatch( )	.../ContainerAwareEventDispatcher.php:167
11	0.1320	4495480	Civi\Core\CiviEventDispatcher->doDispatch( )	.../EventDispatcher.php:53
12	0.1320	4495480	call_user_func:{/var/www/html/testsite/administrator/components/com_civicrm/civicrm/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php:164} ( )	.../EventDispatcher.php:164
13	0.1320	4495480	Civi\Core\CiviEventDispatcher::delegateToUF( )	.../EventDispatcher.php:164
14	0.1320	4495896	CRM_Utils_Hook_Joomla->invokeViaUF( )	.../CiviEventDispatcher.php:86
15	0.1323	4496608	Joomla\CMS\Plugin\PluginHelper::importPlugin( )	.../Joomla.php:81
16	0.1324	4500464	Joomla\CMS\Plugin\PluginHelper::load( )	.../PluginHelper.php:175
17	0.1327	4503232	Joomla\CMS\Factory::getUser( )	.../PluginHelper.php:310
18	0.1327	4503232	Joomla\CMS\Factory::getSession( )	.../Factory.php:254
19	0.1327	4503232	Joomla\CMS\Factory::createSession( )	.../Factory.php:194
20	0.1347	4623504	JSessionHandlerJoomla->__construct( )	.../Factory.php:618
21	0.1347	4623504	ini_set ( )	.../joomla.php:48

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/testsite/libraries/joomla/session/handler/joomla.php:48) in /var/www/html/testsite/libraries/joomla/session/handler/joomla.php on line 110
Call Stack
#	Time	Memory	Function	Location
1	0.0007	363736	{main}( )	.../rest.php:0
2	0.0479	1481080	CRM_Utils_REST->bootAndRun( )	.../rest.php:42
3	0.0479	1481080	CRM_Utils_REST->loadCMSBootstrap( )	.../REST.php:112
4	0.1287	3939912	CRM_Utils_System::loadBootStrap( )	.../REST.php:621
5	0.1287	3939912	CRM_Utils_System_Joomla->loadBootStrap( )	.../System.php:1462
6	0.1319	4494488	CRM_Utils_Hook::config( )	.../Joomla.php:594
7	0.1320	4494488	CRM_Utils_Hook_Joomla->invoke( )	.../Hook.php:1164
8	0.1320	4495480	Civi\Core\CiviEventDispatcher->dispatch( )	.../Hook.php:164
9	0.1320	4495480	Civi\Core\CiviEventDispatcher->dispatch( )	.../CiviEventDispatcher.php:47
10	0.1320	4495480	Civi\Core\CiviEventDispatcher->dispatch( )	.../ContainerAwareEventDispatcher.php:167
11	0.1320	4495480	Civi\Core\CiviEventDispatcher->doDispatch( )	.../EventDispatcher.php:53
12	0.1320	4495480	call_user_func:{/var/www/html/testsite/administrator/components/com_civicrm/civicrm/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php:164} ( )	.../EventDispatcher.php:164
13	0.1320	4495480	Civi\Core\CiviEventDispatcher::delegateToUF( )	.../EventDispatcher.php:164
14	0.1320	4495896	CRM_Utils_Hook_Joomla->invokeViaUF( )	.../CiviEventDispatcher.php:86
15	0.1323	4496608	Joomla\CMS\Plugin\PluginHelper::importPlugin( )	.../Joomla.php:81
16	0.1324	4500464	Joomla\CMS\Plugin\PluginHelper::load( )	.../PluginHelper.php:175
17	0.1327	4503232	Joomla\CMS\Factory::getUser( )	.../PluginHelper.php:310
18	0.1327	4503232	Joomla\CMS\Factory::getSession( )	.../Factory.php:254
19	0.1327	4503232	Joomla\CMS\Factory::createSession( )	.../Factory.php:194
20	0.1352	4627008	Joomla\CMS\Session\Session::getInstance( )	.../Factory.php:621
21	0.1352	4627232	Joomla\CMS\Session\Session->__construct( )	.../Session.php:187
22	0.1352	4627368	JSessionHandlerJoomla->clear( )	.../Session.php:135
23	0.1352	4627408	setcookie ( )	.../joomla.php:110
Error: Failed to start application: Failed to start the session because headers have already been sent by "/var/www/html/testsite/libraries/joomla/session/handler/joomla.php" at line 48.

With this one it's the session_start() in extern/rest.php that leads to the Joomla ini_set() warning.
Joomla does not check for the existence of a session before the ini_set() in its libraries/joomla/session/handler/joomla.php.
I'm still not sure whether we should we try to manage it better in CiviCRM, or to try to get Joomla to implement this open PR, which would also resolve it for us.

@seamuslee001

This comment has been minimized.

Copy link
Contributor

seamuslee001 commented Feb 22, 2018

ping @totten you know a thing or two about the interaction between CiviCRM and the CMS in regards to bootstrapping

@thoni56

This comment has been minimized.

Copy link

thoni56 commented Feb 27, 2018

I suggest that this PR is merged as is, without delaying the solution for many, waiting for a fix for the REST problem (#11609 (comment)).

As it stands, possibly including the deletion of "session_start()" (#11609 (comment)), it fixes issues for users (as in this question on civicrm.stackexchange.com.

@andrewpthompson

This comment has been minimized.

Copy link
Contributor

andrewpthompson commented Mar 1, 2018

@thoni56 Regarding session_start() I think there would need to be something like conditionally skipping it for Joomla (3.8+) but then in CRM_Core_Session::initialize after session_start() CiviCRM does a couple more things such as $this->_session =& $_SESSION; and $this->_session[$this->_key] = array();.
While as a quick & dirty test, removing sessions_start() seems to fix the problem I don't know enough to be able to say that it won't affect anything else.
IF my approach in this PR currently is ok then I guess that as CRM-21203 is strictly speaking for cli.php (not cron.php or REST) then you are correct that this PR could be unmarked as WIP so that it could be reviewed & merged. I was hoping to get all of the cron-related problems resolved but I take your point that this problem has been outstanding for some time now.

@andrewpthompson andrewpthompson changed the title [WIP] CRM-21203 revisited - Joomla 3.8 extra fixes for cron CRM-21203 revisited - Joomla 3.8 extra fixes for cli.php Mar 5, 2018

@andrewpthompson

This comment has been minimized.

Copy link
Contributor

andrewpthompson commented Mar 5, 2018

I've unmarked as 'WIP' following Brian's comment on JIRA.
To be clear this PR fixes cli.php but does not fix cron.php for all environments (PHP 7).

@lcdservices

This comment has been minimized.

Copy link
Contributor

lcdservices commented Mar 5, 2018

@andrewpthompson FWIW -- I tested on my dev site and switched between PHP5.6 and PHP7.0 and it worked properly on both when run via cron.php. I was only testing cron.php, as it seemed that was the potential outstanding issue. So if others are finding it's not running, it may be another factor besides the version.

@eileenmcnaughton

This comment has been minimized.

Copy link
Contributor

eileenmcnaughton commented Mar 23, 2018

Reading the comments I feel like there is general agreement to merge this & that it fixes an identifiable problem without any identified problems. The issue is narrowly scoped to affecting Joomla! and I think the people who know Joomla! best have indicated support for this - so I'm going to merge

@eileenmcnaughton eileenmcnaughton merged commit 8a35144 into civicrm:master Mar 23, 2018

1 check passed

default Build finished.
Details
@adam-devapp

This comment has been minimized.

Copy link

adam-devapp commented Jun 6, 2018

Thanks everyone for the fixes. The warning was still shown after applying the various fixes, but the cron now runs using PHP 7.1 and CiviCRM 5.1.2. Through debugging cron.php, I found the wrong time zone was contributing to the issue, even though it was set correctly in Joomla, the master php configuration and on the server. Just wanted to note here incase someone else has the issue and the fixes above don't fully resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment