Maybe you can change these lines by this:

if (!(int)$id_lang)
			$id_lang = (int)Configuration::get('PS_LANG_DEFAULT');