Errors like "Illegal string offset" and locales

Hello All,

For some time now I’ve been trying to upgrade our OJS from 2.4.7 to 3.0.2. It’s not finished yet but the problems are slowly being solved. The last one I found is a bunch of:

Warning: Illegal string offset 'pt_BR' in /ojs_temp/rc-3.0.2/lib/pkp/classes/core/DataObject.inc.php on line 133

That I suspect can be the same thing discussed here:

In fact, my user_settings have some blank/weird values for locales:

> +---------------+--------+----------+
> | setting_name  | locale | count(1) |
> +---------------+--------+----------+
> | affiliation   | en_US  |     1832 |
> | affiliation   | es_ES  |       13 |
> | affiliation   | pt_BR  |    26689 |
> | biography     |        |     9301 |
> | biography     | 0      |      435 |
> | biography     | en_US  |     1515 |
> | biography     | es_ES  |       84 |
> | biography     | pt_BR  |    17589 |
> | filterEditor  |        |      116 |
> | filterSection |        |      163 |
> | gossip        | en_US  |      337 |
> | gossip        | pt_BR  |     1442 |
> | orcid         |        |     4580 |
> | profileImage  |        |      156 |
> | signature     |        |     9301 |
> | signature     | 0      |      435 |
> | signature     | en_US  |     1585 |
> | signature     | es_ES  |       84 |
> | signature     | pt_BR  |    18408 |
> +---------------+--------+----------+

And in some cases, the setting_value field is null. The same happens for the author_settings table and may happen to others. Wich is the best way to solve the issue? Can I set the blank/invalid locales to pt_BR? And what about the empty setting_value fields? Can those records be deleted? Which other tables should I check?

Thanks in advance,

Oberdan

Hi @Oberdan,

Some settings are localized (locale should be like xx_YY); those are the ones for which you can enter data in multiple languages, such as the user’s signature.

Other settings are not localized (locale should be empty/null); those are the ones for which data is not language-specific (e.g. the ORCiD).

Those 0s don’t make any sense to me, so I’d suggest removing them. The other case that might cause problems is if you have mixed data – some localized and some not – in which you’ll get warnings along the lines of “illegal string offset”.

[Edited: I accidentally referred to the locale column as setting_value]

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Thanks for the quick reply. Where you say that “setting_value” is xx_YY for localized and blank/null for not localized is it really the “setting_value” field or is it the “locale” field?

I don’t know why there are zeros in those locale fields, but inspecting the records I saw some of them have a non-blank value on setting_value and for those cases the correct locale would be pt_BR. For the others setting_value is blank so I think it can be deleted.

In the thread I cited you said:

Not all entries in user_settings are supposed to be localized – in OJS 2.4.6, it’s biography, signature, gossip, and affiliation entries. The others should have a blank locale column.

So, is it correct to say that biography, signature, gossip and affiliation must be localized, and having some records with a blank locale field cause the “illegal string offset” error?

Is this the case for the authors_settings table too?

Regards,

Oberdan

Hi @Oberdan,

Where you say that “setting_value” is xx_YY for localized and blank/null for not localized is it really the “setting_value” field or is it the “locale” field?

Sorry, my typo; I’ve corrected it in the post above.

So, is it correct to say that biography, signature, gossip and affiliation must be localized, and having some records with a blank locale field cause the “illegal string offset” error?

In OJS 3.0.2, in user_settings, the following settings should always have a valid locale specified: biography, signature, gossip, and affiliation

In OJS 3.0.2, in author_settings, the following settings should always have a valid locale specified: biography, competingInterests, affiliation

There should never be a case where, for a given setting_name, some rows have a locale set and others don’t. That would probably be the cause of the Illegal string offset warning.

Note that plugins may use these tables to store additional settings beyond the ones that are coded in the distribution, and those may or may not be localized.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Thanks for the explanation. One last question: is it correct to have records in users_settings or in author_settings where the setting_value is null/blank/filled with blank spaces?

Regards,

Oberdan

Hi @Oberdan,

I don’t believe we filter for blanks before storing settings, so yes, there will probably be valid cases where setting_value is empty.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Locales fixed, and no more “Illegal string offset” errors. Thanks for your help.

Regards,

Oberdan

Hi @Oberdan,

Excellent, glad to hear it!

Regards,
Alec Smecher
Public Knowledge Project Team