Skip to content

Commit

Permalink
Improve Performance of check on published content langs.
Browse files Browse the repository at this point in the history
Fixees joomla#7130. References joomla#6904
  • Loading branch information
wilsonge authored and johanjanssens committed Jun 19, 2015
1 parent 28f11da commit 141525e
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions plugins/system/languagefilter/languagefilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ class PlgSystemLanguageFilter extends JPlugin

private $user_lang_code;

/**
* JDatabaseDriver instance
*
* @var JDatabaseDriver
* @since 3.4.2
*/
protected $db = null;

/**
* Application object.
*
Expand Down Expand Up @@ -522,24 +514,17 @@ public function onUserLogin($user, $options = array())
$assoc = JLanguageAssociations::isEnabled();
$lang_code = $user['language'];

// If no language is specified for this user, we set it to the site default language
if (empty($lang_code))
{
$lang_code = $this->default_lang;
}

// Get a 1-dimensional array of published language codes
$query = $this->db->getQuery(true)
->select($this->db->quoteName('a.lang_code'))
->from($this->db->quoteName('#__languages', 'a'))
->where($this->db->quoteName('published') . ' = 1');
$this->db->setQuery($query);
$lang_codes = $this->db->loadColumn();

// The user language has been deleted/disabled or the related content language does not exist/has been unpublished
// The language has been deleted/disabled or the related content language does not exist/has been unpublished
// or the related home page does not exist/has been unpublished
if (!array_key_exists($lang_code, MultilangstatusHelper::getSitelangs())
|| !in_array($lang_code, $lang_codes)
|| !array_key_exists($lang_code, MultilangstatusHelper::getHomepages()))
if (!array_key_exists($lang_code, $this->lang_codes)
|| !array_key_exists($lang_code, MultilangstatusHelper::getHomepages())
|| !JFolder::exists(JPATH_SITE . '/language/' . $lang_code))
{
$lang_code = $this->current_lang;
}
Expand Down

0 comments on commit 141525e

Please sign in to comment.