diff --git a/libraries/cms/component/helper.php b/libraries/cms/component/helper.php index 868801eccdc2c..3a68ba5feda58 100644 --- a/libraries/cms/component/helper.php +++ b/libraries/cms/component/helper.php @@ -462,17 +462,46 @@ protected static function load($option) } catch (RuntimeException $e) { - // Fatal error. - JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $e->getMessage()), JLog::WARNING, 'jerror'); + /* + * Fatal error + * + * It is possible for this error to be reached before the global JLanguage instance has been loaded so we check for its presence + * before logging the error to ensure a human friendly message is always given + */ + + if (JFactory::$language) + { + $msg = JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $e->getMessage()); + } + else + { + $msg = sprintf('Error loading component: %1$s, %2$s', $option, $e->getMessage()); + } + + JLog::add($msg, JLog::WARNING, 'jerror'); return false; } if (empty(static::$components[$option])) { - // Fatal error. - $error = JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'); - JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $error), JLog::WARNING, 'jerror'); + /* + * Fatal error + * + * It is possible for this error to be reached before the global JLanguage instance has been loaded so we check for its presence + * before logging the error to ensure a human friendly message is always given + */ + + if (JFactory::$language) + { + $msg = JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); + } + else + { + $msg = sprintf('Error loading component: %1$s, %2$s', $option, 'Component not found.'); + } + + JLog::add($msg, JLog::WARNING, 'jerror'); return false; }