K
K
koskanalya2019-10-14 11:22:04
Joomla
koskanalya, 2019-10-14 11:22:04

How to fix PHP Fatal error: Class 'Joomla\\Registry\\Registry'?

After enabling the plugin Content - DJReviews site crashes with 500 error (Joomla 2.5)
PHP Fatal error: Class 'Joomla\\Registry\\Registry' not found in /components/com_djreviews/helpers/djreviews.php on line 45
Line with error
$groupParams = new Registry($groupParams);
Maybe someone has come across this?
Full code

<?php
/**
 * @version $Id: djreviews.php 53 2016-12-29 11:59:48Z michal $
 * @package DJ-Reviews
 * @copyright Copyright (C) 2014 DJ-Extensions.com LTD, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 *
 * DJ-Reviews is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * DJ-Reviews is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DJ-Reviews. If not, see <http://www.gnu.org/licenses/>.
 *
 */
use Joomla\Registry\Registry;

defined('_JEXEC') or die('Restricted access');

class DJReviewsHelper {
  
  protected static $params = array();
  protected static $assets = false;
  
  public static function getParams($group_id = 0) {
    $group_id = (int)$group_id;
    if (!isset(self::$params[$group_id])) {
      if ($group_id == 0) {
        self::$params[$group_id] = JComponentHelper::getParams('com_djreviews');
      } else {
        $globalParams = JComponentHelper::getParams('com_djreviews');
        $db = JFactory::getDbo();
        $db->setQuery('SELECT params FROM #__djrevs_rating_groups WHERE id='.$group_id);
        $groupParams = $db->loadResult();
        if (!empty($groupParams)) {
          $groupParams = new Registry($groupParams);
          $globalParams->merge($groupParams); 
        }
        self::$params[$group_id] = $globalParams;
      }
    }
    return self::$params[$group_id];
  }
  
  public static function setAssets($group_id = 0){
        if (!self::$assets) {
            $params = self::getParams($group_id);
            
            $lang = JFactory::getLanguage();
            $lang->load('com_djreviews', JPATH_ROOT, 'en-GB', false, false);
            $lang->load('com_djreviews', JPATH_ROOT.JPath::clean('/components/com_djreviews'), 'en-GB', false, false);
            $lang->load('com_djreviews', JPATH_ROOT, null, true, false);
            $lang->load('com_djreviews', JPATH_ROOT.JPath::clean('/components/com_djreviews'), null, true, false);
            
            //JHtml::_('behavior.tooltip', '.djrv_tooltip');
            JHtml::_('bootstrap.popover', '.djrv_tooltip');
            
            $theme = $params->get('theme', 'bootstrap');
            $document = JFactory::getDocument();
            $cookie = JFactory::getApplication()->input->cookie;
            
            $isRTL = false;
            if (isset($document->direction) && $document->direction=='rtl'){
                $isRTL = true;
            } else if ($cookie->get('jmfdirection')){
                if ($cookie->get('jmfdirection')=='rtl'){
                    $isRTL = true;
                }
            } else if ($cookie->get('djdirection')){
                if ($cookie->get('djdirection')=='rtl'){
                    $isRTL = true;
                }
            }
            
            $css_suffix = ($isRTL) ? '.rtl' : '';
            
            JFactory::getDocument()->addStyleSheet(JUri::base().'components/com_djreviews/themes/'.$theme.'/css/theme'.$css_suffix.'.css');
      
            self::$assets = true;
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton R., 2019-10-14
@anton_reut

Throw out this plugin, because it is clumsily written, which is displayed in the error text.

Error line
$groupParams = new Registry($groupParams);
- This means that it is trying to create a Registry object by passing a variable to it, but most likely this class is simply not included in your code. Perhaps this path is not correct: use Joomla\Registry\Registry; (this is just the "connection" of classes).
And update Joomla, already 3.9.12 and not 2.5
https://forum.joomla.org/viewtopic.php?t=945598

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question