Jump to content

One language crashing(the rest works) with Friendly URL's enabled


asdqwerty

Recommended Posts

Hi

 

These are the errors:

 

PHP Warning: Missing argument 1 for ToolsCore::setCurrency(), called in 
/classes/Tools.php on line 427 and defined in /classes/Tools.php on line 439
 
PHP Notice: Undefined variable: cookie in /classes/Tools.php on line 450
 
PHP Notice: Trying to get property of non-object in /classes/Tools.php on line 450
 
PHP Strict Standards: Creating default object from empty value in /classes/Tools.php on line 455
 
This is the modifications I've made to Tools.php :
 
first line is 379
public static function switchLanguage(Context $context = null)
	{
		if (!$context)
			$context = Context::getContext();
		
		// Install call the dispatcher and so the switchLanguage
		// Stop this method by checking the cookie
		if (!isset($context->cookie))
			return;

		if (($iso = Tools::getValue('isolang')) && Validate::isLanguageIsoCode($iso) && ($id_lang = (int)Language::getIdByIso($iso)))
			$_GET['id_lang'] = $id_lang;

		// update language only if new id is different from old id
		// or if default language changed
		$cookie_id_lang = $context->cookie->id_lang;
		$configuration_id_lang = Configuration::get('PS_LANG_DEFAULT');
		if ((($id_lang = (int)Tools::getValue('id_lang')) && Validate::isUnsignedId($id_lang) && $cookie_id_lang != (int)$id_lang)
			|| (($id_lang == $configuration_id_lang) && Validate::isUnsignedId($id_lang) && $id_lang != $cookie_id_lang))
		{
			$context->cookie->id_lang = $id_lang;

			$language = new Language($id_lang);
			if (Validate::isLoadedObject($language) && $language->active)
				$context->language = $language;

			$params = $_GET;
			if (Configuration::get('PS_REWRITING_SETTINGS') || !Language::isMultiLanguageActivated())
				unset($params['id_lang']);
				
			switch($id_lang) {
				case 1: //if lang_id that's changed to is = 1 than...
					self::switchCurrencyLinked(2);
				break;
				case 2: //and so on ....
					self::switchCurrencyLinked(1);
				break;
				case 3: //and so on ....
					self::switchCurrencyLinked(2);
				break; 
			}
		}
	}
	
	static public function switchCurrencyLinked($cookieLanguage) {
		global $cookie;
		if (! (int)$cookie->id_currency_changed) {
		    $cookie->id_currency = $cookieLanguage;
		    self::setCurrency();
		}
		else {
			    $cookie->id_currency_changed = 0;
		}
	}
Unfortunately I don't really remember what I've added, but I think its the "switchCurrencyLinked" and the switch at the end inside switchLanguage
 
I have english, swedish and finnish on the site, and when its switched to finnish the page is all blank and I see the errors that are at the top of the post.
 
Anyone have any idea what the problem might be?
Edited by asdqwerty (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...