0

Receiving the following error when trying to browse for a link in Message templates:

Exception:
Failed to start application

  at /var/www/joomla/libraries/src/Factory.php:158
  at Joomla\CMS\Factory::getApplication()
     (/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/integration/civicrm.php:203)
  at authenticate_joomla()
     (/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/integration/civicrm.php:73)
  at checkAuthentication()
     (/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/integration/civicrm.php:212)
  at require('/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/integration/civicrm.php')
     (/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/core/bootstrap.php:39)
  at require('/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/core/bootstrap.php')
     (/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/browse.php:15)           

How can i resolve?

enter image description here enter image description here enter image description here

3
  • I'd try to replace line 203 in ../civicrm.php as "JFactory::" is deprecated in Joomla 5 and must be replaced. I raised an issue 6 days ago. lab.civicrm.org/dev/joomla/-/issues/55
    – Guitarman
    Commented Apr 16 at 16:15
  • this is in joomla 4 Commented Apr 17 at 7:53
  • made changes per your proposed change, and Factory could no longer be found Commented Apr 17 at 8:00

2 Answers 2

2
+25

Have you tried using CKeditor5 or summernote as a replacement got Kcfinder?

1
  • Ckeditor is fine, but you lose the ability to browse for links Commented Apr 24 at 11:25
1

Please change the file administrator/civicrm/packages/kcfinder/integration/civicrm.php and use the following code for the function authenticate_joomla near the end of the file (line 193 f.) to the following:

function authenticate_joomla($config) {

  $joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));

  define( '_JEXEC', 1 );
  define('JPATH_BASE', $joomlaBase);
  define( 'DS', DIRECTORY_SEPARATOR );
  require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
  require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

if (version_compare(JVERSION, '4.0.0', 'lt')) {
    $mainframe = JFactory::getApplication('administrator');
    $mainframe->initialise();
    
    $user_id = JFactory::getUser()->id;
  } 
  else {
    $container = \Joomla\CMS\Factory::getContainer();

    $container->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');

    $app = $container->get(\Joomla\CMS\Application\AdministratorApplication::class);
    
    $user_id = Joomla\CMS\Factory::getUser()->id;
  }

  if (JFactory::getUser()->id == 0) {
    return false;
  }
  return true;
}

I tested this successfully.

3
  • 1
    We have to avoid using JFactory::getApplication('administrator') as since Joomla 4 'getApplication' no longer takes arguments. From the J4 potential backward compatibility page, docs.joomla.org/…
    – Guitarman
    Commented Apr 24 at 9:10
  • I will test this first chance I get Commented Apr 24 at 11:25
  • could you test this already?
    – Guitarman
    Commented Apr 29 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.