In Drupal 7.35, with Views 7.x-3.10, Internationalization 7.x-1.12, Internationalization Views 7.x-3.x-dev (2014-Oct-23 ) , Better Exposed Filters 7.x-3.0 - after update BEF to 7.x.-3.1 get Notice:

Notice: Array to string conversion in i18nviews_plugin_localization_i18nstrings->stringid() (line 66 of /var/www/ .......................sites/all/modules/i18nviews/includes/i18nviews_plugin_localization_i18nstrings.inc).

After installing of BEF 7.x-3.0, notice disappeared.

Could this be changed to accept arrays?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NIKS_Artreaktor’s picture

Start from version better_exposed_filters 7.x-3.1
Release notes
The main change in this release is that BEF now provides translations for all BEF setting strings. Yea for translations! However...

BEF has his own translation.

I so that in array $keys ( Array of keys for the string to be translated.) not integer key - are BEF added keys.
It is maybe not the best fix for this problem, but I filtering array with keys (line 66) to only integer key.
So, I changed function function stringid($keys) to

  function stringid($keys) {
		
			foreach ($keys as $key => $value) {
					if (!is_int($key)) {
							unset($keys[$key]);
					}
			}
			
			return 'views:' . implode(':', $keys);
		 
		
  }

But, another way to fix it - implode second array, that inside. Then we seems to me will can to translate BEF strings.

Here is the code

 function stringid($keys) {
 
	foreach($keys AS $key => $value) {
		if(is_array($value)) 
		{ 
					$keys[ $key ] = implode(':', $value); 
		}
	}
			 
	return 'views:' . implode(':', $keys);
  }
mitkompm’s picture

NIKS_Artreaktor, thank you.
Have tried second way, it works with BEF 7.x-3.2 edition. No errors.

Chris7419’s picture

Hi i have the same error like mitkompm! If i update BEF from 7.x-3.0 to 7.x.-3.1 or 7.x-3.2 i get the "Array to string conversion in i18nviews_plugin_localization_i18nstrings". BEF works only with 7.x-3.0 edition.

mitkompm’s picture

Chris7419, you should apply change of code ("patch") from #1 to i18nviews/plugins/i18nviews_plugin_localization_i18nstrings.inc.

mikeker’s picture

I think the root of the problem is that BEF removed it's support for I18N Strings-based translations in 3.1, using core's Locale module and Views' default localization plugin. The hope was to give a more consistent interface to translate all BEF settings rather than the single one that had been wired up to work with I18N Strings. Anyhow, I expected there would be some fallout from this change and I apologize for it.

I'm guessing that the string translations for BEF are still in the I18N datastore. Can you try deleting the translation for the BEF exposed sort settings and see if the PHP notice goes away? (You may want to save the translation before deleting it as you'll need to add it to admin/config/regional/translate/translate. See the handbook page for details.)

jaydee1818’s picture

My logs are getting smashed with this error message since upgrading to the latest version of BEF.

In this case I am using a filter based on a taxonomy term. I tried removing the translations of each term (which was tedious) plus the translation of the label within the i18N Views translation interface. The translation for "- Any -" seems to be automatic so I was unable to do anything about that. To cut a long story short, I couldn't fix it. Reverting back to previous version of BEF for now.

Perhaps there is a smooth process for upgrading?

PlayfulWolf’s picture

@mikeker, my pages are spammed with those warnings - what exact steps should I (we) do? Site is multilingual, so there is many strings to delete

mikeker’s picture

@jaydee1818, @PlayfulWolf, I'm sorry for the headaches the latest BEF update is causing.

I just tried moving between BEF 3.0 and 3.2 with a translated exposed sort string and, I agree, it's causing all sorts of warnings. There is only one BEF string in translation in 3.0 -- the exposed sort rewrite setting -- so I'm not sure why it's causing a warning for each string in translation when you upgrade beyond 3.0. At this point I haven't found a good way to clean up the notices through the UI. I'd recommend using the suggestion in #1.

Perhaps the root of the problem is being able to remove strings from the translation database when a module is uninstalled (or, in this case, upgraded to a version that no longer supports the i18n module). I'll try to look into this some more tomorrow...

bdupls’s picture

I had this error also. You have to take care not to have better_exposed_filters used in views if you change to basic filters then disable better exposed filters, error goes away.
Maybe a check in the module should exist to prevent disabling if used in views.

mikeker’s picture

@bettledupls: See #1182064: Fatal error after disabling Better Exposed Filters. But there's a bit of a chicken-and-egg problem -- that check was added after the I18N code was removed, so it doesn't help is this situation.

Thanks for posting your workaround.

michel.settembrino’s picture

I had the same issue. I have tried second way (from #1) and it works with Better Exposed Filters version 7.x-3.2
I created a patch file that does this changes. See array_to_string_conversion_in_i18nviews_plugin_localization_i13nstrings-2464901-11.patch

langweer’s picture

Thank you for the patch!
I ran into the same issue when updating BEF from 7.x-3.0 to 7.x-3.2. After I applied the patch, not more errors are logged.

matthiasm11’s picture

Status: Active » Reviewed & tested by the community

I can confirm the patch from #11 works.

NIKS_Artreaktor’s picture

Can anybody say what solution from #1 better?

In FIRST solution BEF string will translate elsewhere.
In SECOND solution BEF string it seems to me will translate in Internationalization Views table of views translation.

Goekmen’s picture

I can confirm the patch from #11 too.

Daemon_Byte’s picture

can also confirm the patch

tormu’s picture

+1 for the patch #11

rcodina’s picture

+1 for patch on #11

nizer’s picture

+1 for patch on #11

olak’s picture

+1 for patch on #11
worked for views 3.11, BEF 3.2

webflo’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the reviews!

dqd’s picture

webflo++
jonhattan++
MS-Informatique++

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.