Answers.Body: <p>I have updated Joomla to 3.8.5 and updated CiviCRM to 4.7.31 (I'm using PHP version 5.6.34.) and the CRON job <strong>still</strong> didn't work.</p>
  
  <p>I found and applied this <a href="https://github.com/civicrm/civicrm-core/pull/11609" rel="nofollow noreferrer">patch</a> and it worked. Thank you to <a href="https://civicrm.stackexchange.com/users/2194/andrew-thompson">Andrew Thompson</a> for your work on this issue.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T02:21:06.197Z
Answers.LastActivityDate: 2018-03-09T02:21:06.197Z
Answers.UserDisplayName: Ash Lock
Answers.Body: <p>It looks like import.legacy.php is re-definining existing constants (or called twice)</p>
  
  <p>I'm not familiar with Joomla, but can you try to remove requiring this file in civi (comment out line 565 in that file)</p>
  
  <p><a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/System/Joomla.php#L565" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/System/Joomla.php#L565</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-06T11:49:16.993Z
Answers.Text: There are still some problems in CRM/Utils/System/Joomla.php. When I was looking at CRM-21203 I did notice that CiviCRM should not be requiring both of Joomla's `import.php` and `import.legacy.php` as the content of [import.php](https://github.com/joomla/joomla-cms/blob/staging/libraries/import.php) is really a subset of [import.legacy.php](https://github.com/joomla/joomla-cms/blob/staging/libraries/import.legacy.php)
  But there is still something else that stops cron.php working.
Answers.UserDisplayName: Andrew Thompson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-03T06:49:15.860Z
Answers.LastActivityDate: 2017-11-03T06:49:15.860Z
Answers.UserDisplayName: Xavier
Body: <p>After upgrading Joomla to 3.8.1 the cron job stopped working as reported <a href="https://civicrm.stackexchange.com/questions/20492/issues-with-running-joomla-3-8-and-civi" title="here">here</a>. I have applied the update the Joomla.php file as suggested in the <a href="https://civicrm.stackexchange.com/a/20802/4248" title="answers">answers</a>. This gets rid of the original error. However now I am getting this error:
  <code>
      PHP Notice:  Constant JPATH_ISWIN already defined in /home/fava/public_html/libraries/import.legacy.php on line 64
      Notice: Constant JPATH_ISWIN already defined in /home/fava/public_html/libraries/import.legacy.php on line 64
      PHP Notice:  Constant JPATH_ISMAC already defined in /home/fava/public_html/libraries/import.legacy.php on line 65
      Notice: Constant JPATH_ISMAC already defined in /home/fava/public_html/libraries/import.legacy.php on line 65
      PHP Notice:  Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.legacy.php on line 72
      Notice: Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.legacy.php on line 72
      PHP Notice:  Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.legacy.php on line 79
      Notice: Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.legacy.php on line 79
      PHP Notice:  Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.php on line 60
      Notice: Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.php on line 60
      PHP Notice:  Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.php on line 67
      Notice: Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.php on line 67
      <b>Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/home/fava/public_html/libraries/import.legacy.php" at line 64.</b>
  </code></p>
  
  <p>I have tried manually clearing the Joomla session table but no luck.
  I have also update CiviCRM to 4.7.27 and applied the patches as mentioned <a href="https://civicrm.stackexchange.com/a/21166/4248%20here">here</a> but the same error is still occurring.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-06T11:42:58.917Z
Comments.Text: I've just tested this again and I'm not convinced that the patch for CRM-21203 works for cron jobs that call `cron.php`, only `cli.php`. Your output looks as though you are using cron.php; as a workaround you could try having the cron job execute `php /path/to/civicrm/bin/cli.php -s site -u user -p password -e Job -a execute`
  Note: I am also getting the PHP notices for constant already defined but they do not stop the job running via cli.php.
Comments.UserDisplayName: Andrew Thompson
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-07T22:51:55.720Z
Comments.Text: Thanks Andrew, I am getting the errors using cli.php so I decided to change to cron.php and the cron job is now executing, not all the the jobs are running properly but atleast the we are starting to get somewhere
Comments.UserDisplayName: Ash Lock
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-08T23:23:20.103Z
Comments.Text: I should mention that for me even using cli.php there are still Notices, but the scheduled jobs run properl. But with cli.php I don't the Application Instantiation Error at the end - I only get that with cron.php.
Comments.UserDisplayName: Andrew Thompson
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-02T14:12:51.940Z
Comments.Text: I think there are still problems on CiviCRM 4.7.28. I've added to the existing issue [here](https://issues.civicrm.org/jira/browse/CRM-21203?focusedCommentId=111804&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-111804)
Comments.UserDisplayName: Andrew Thompson
Tags: <joomla><cron-job>
Title: Cron Job not working after Joomla 3.8.1 update
ThreadText: # Cron Job not working after Joomla 3.8.1 update
  
  (Asked by: username_0 on 2017-11-03)
  
  After upgrading Joomla to 3.8.1 the cron job stopped working as reported [here](https://civicrm.stackexchange.com/questions/20492/issues-with-running-joomla-3-8-and-civi "here"). I have applied the update the Joomla.php file as suggested in the [answers](https://civicrm.stackexchange.com/a/20802/4248 "answers"). This gets rid of the original error. However now I am getting this error:
  `PHP Notice: Constant JPATH_ISWIN already defined in /home/fava/public_html/libraries/import.legacy.php on line 64
  Notice: Constant JPATH_ISWIN already defined in /home/fava/public_html/libraries/import.legacy.php on line 64
  PHP Notice: Constant JPATH_ISMAC already defined in /home/fava/public_html/libraries/import.legacy.php on line 65
  Notice: Constant JPATH_ISMAC already defined in /home/fava/public_html/libraries/import.legacy.php on line 65
  PHP Notice: Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.legacy.php on line 72
  Notice: Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.legacy.php on line 72
  PHP Notice: Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.legacy.php on line 79
  Notice: Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.legacy.php on line 79
  PHP Notice: Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.php on line 60
  Notice: Constant JROUTER_MODE_RAW already defined in /home/fava/public_html/libraries/import.php on line 60
  PHP Notice: Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.php on line 67
  Notice: Constant JROUTER_MODE_SEF already defined in /home/fava/public_html/libraries/import.php on line 67
  Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/home/fava/public_html/libraries/import.legacy.php" at line 64.`
  
  I have tried manually clearing the Joomla session table but no luck.
  I have also update CiviCRM to 4.7.27 and applied the patches as mentioned [here](https://civicrm.stackexchange.com/a/21166/4248%20here) but the same error is still occurring.
  
  **Tags:** joomla, cron-job
  
  > **Comments:**
  > **username_1**: I've just tested this again and I'm not convinced that the patch for CRM-21203 works for cron jobs that call `cron.php`, only `cli.php`. Your output looks as though you are using cron.php; as a workaround you could try having the cron job execute `php /path/to/civicrm/bin/cli.php -s site -u user -p password -e Job -a execute` Note: I am also getting the PHP notices for constant already defined but they do not stop the job running via cli.php.  
  > **username_0**: Thanks username_1, I am getting the errors using cli.php so I decided to change to cron.php and the cron job is now executing, not all the the jobs are running properly but atleast the we are starting to get somewhere  
  > **username_1**: I should mention that for me even using cli.php there are still Notices, but the scheduled jobs run properl. But with cli.php I don't the Application Instantiation Error at the end - I only get that with cron.php.  
  > **username_1**: I think there are still problems on CiviCRM 4.7.28. I've added to the existing issue [here](https://issues.civicrm.org/jira/browse/CRM-21203?focusedCommentId=111804&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-111804)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2018-03-09. Score: 1 | Accepted answer
  
  I have updated Joomla to 3.8.5 and updated CiviCRM to 4.7.31 (I'm using PHP version 5.6.34.) and the CRON job **still** didn't work.
  
  I found and applied this [patch](https://github.com/civicrm/civicrm-core/pull/11609) and it worked. Thank you to [username_1 username_1](https://civicrm.stackexchange.com/users/2194/username_1) for your work on this issue.
  
  
  ---
  
  ### Answer by username_2 on 2017-11-03. Score: 0
  
  It looks like import.legacy.php is re-definining existing constants (or called twice)
  
  I'm not familiar with Joomla, but can you try to remove requiring this file in civi (comment out line 565 in that file)
  
  <https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/System/Joomla.php#L565>
  
  > **Comments:**
  > **username_1**: There are still some problems in CRM/Utils/System/Joomla.php. When I was looking at CRM-21203 I did notice that CiviCRM should not be requiring both of Joomla's `import.php` and `import.legacy.php` as the content of [import.php](https://github.com/joomla/joomla-cms/blob/staging/libraries/import.php) is really a subset of [import.legacy.php](https://github.com/joomla/joomla-cms/blob/staging/libraries/import.legacy.php) But there is still something else that stops cron.php working.  
  
  ---
  
  