?
avatar StefanLindner
StefanLindner
5 Jul 2017

the affected file: administrator/components/com_finder/helpers/indexer/stemmer/snowball.php

        public function stem($token, $lang)
        {
                // Language to use if All is specified.
                static $defaultLang = '';

                // If language is All then try to get site default language.
                if ($lang == '*' && $defaultLang == '')
                {
                        $languages = JLanguageHelper::getLanguages();
                        $defaultLang = isset($languages[0]->sef) ? $languages[0]->sef : '*';
                        $lang = $defaultLang;
                }

                // Stem the token if it is not in the cache.
                if (!isset($this->cache[$lang][$token]))
                {
                        // Get the stem function from the language string.
                        switch ($lang)
                        {
                                // Danish stemmer.
                                case 'da':
                                        $function = 'stem_danish';
                                        break;

                                // German stemmer.
                                case 'de':
                                        $function = 'stem_german';
                                        break;

                                // English stemmer.
                                default:
                                case 'en':
                                        $function = 'stem_english';
                                        break;

Expected result

If the function parameter $lang has the value '*' it should be changed to ```$defaultLang````

Actual result

$lang has the value '*'

System information (as much as possible)

independent of specific system, Joomla PHP code only

Comments

Normally -- if the language for an article ist not specified explicitly -- the language value i '*'

The first time the function stem ist called, the $defaultLang ist not defined and thus will correctly be initialized to the site's default language. $language ist changed to $defaultLang and the switch statement selects the correct stem_function.

The next time the function stem ist called, $defaultLang no longer hat the value '' and the if statement is skipped. $language will keep ist's value '*' and the switch statement rund into it's default branch selecting stem_english.

Every further call of the function stem uses stem_english regardless the site's default language.

Possible Solution

			// If language is All then try to use site default language.
			if ($lang == '*')
			{
				if ($defaultLang == '')
				{
					// Try to get site default language.
					$languages = JLanguageHelper::getLanguages();
					$defaultLang = isset($languages[0]->sef) ? $languages[0]->sef : '*';
				}

				$lang = $defaultLang;
			}
avatar StefanLindner StefanLindner - open - 5 Jul 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Jul 2017
avatar infograf768
infograf768 - comment - 6 Jul 2017

@chrisdavenport

Can you have a look ?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16981.

avatar chrisdavenport
chrisdavenport - comment - 6 Jul 2017

@StefanLindner I agree with your analysis of the problem and your suggested solution looks good. Can you submit a PR?

avatar joomla-cms-bot joomla-cms-bot - change - 6 Jul 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 6 Jul 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Jul 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-07-06 12:57:35
Closed_By franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 6 Jul 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 6 Jul 2017

closed as having PR #17002


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16981.

Add a Comment

Login with GitHub to post a comment