Array_map(): Argument #2 should be an array

Hello everyone,

I set up a pre-production environment to plan the migration from OJS 2.4 to version 3.X.

The problem is that some items are not displayed on the administration page.

Administration - Hosted Journals - Edit the existing journal
Captura de tela de 2020-08-14 16-28-57

Analyzing the logs, I see some messages similar to the one below:

[php7:warn] [pid 15745] [client xxxxx] PHP Warning:  array_map(): Argument #2 should be an array in /www/ojs-3.2.1-1/lib/pkp/controllers/grid/admin/context/ContextGridHandler.inc.php on line 218, referer: http://xxx/index.php/rvq/admin/contexts
[php7:warn] [pid 15745] [client xxxxx] PHP Warning:  Invalid argument supplied for foreach() in /www/ojs-3.2.1-1/lib/pkp/classes/components/forms/FormComponent.inc.php on line 331, referer: http://xxxx/index.php/rvq/admin/contexts

[php7:warn] [pid 15745] [client xxxxxx:59478] PHP Warning:  array_values() expects parameter 1 to be array, null given in /www/ojs-3.2.1-1/lib/pkp/classes/components/forms/FormComponent.inc.php on line 301, referer: http://xxxxxx/index.php/rvq/admin/contexts

Does anyone have any ideas to solve this?

Regards,

Renato L. Sousa

Hi @rensousa,

What specific version of OJS 3.x are you working to upgrade to?

The warnings you list shouldn’t cause problems, but they may hide a more relevant error message elsewhere in the log. Look for the word Error.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

The version used for the migration is 3.2.1-1.

There are no messages at the ERROR level in the logs.

I deduced that it was related since the messages are displayed in the log immediately when I access the area that does not display any information.

How can I debug better to find the problem?
Is it an inconsistency in the database?

Regards,

Renato L. Sousa

Hi @rensousa,

The warnings seem to be related to your language settings. I’d suggest reviewing and re-saving your language settings form, if that’s possible.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Thanks a lot for the help!
I reinstalled the Portuguese (Brazil) language (pt-BR) and the boxes display the text normally.

I see that in the language configurations (Administration - Site Settings - Language) several items without locale name of languages.

Captura de tela de 2020-08-20 11-30-52

How can I remove them from the list?

Best regards,

Renato L. Sousa

Hi @rensousa,

What do you see for the following SQL query?

SELECT installed_locales, supported_locales FROM site;

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Below is the return of the SQL sentence.

SELECT installed_locales, supported_locales FROM site;
    +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
    | installed_locales                                                                                                                                                                                                                                                                            | supported_locales                                                                                                                               |
    +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
    | a:18:{i:0;s:1:"a";i:1;s:1:"4";i:2;s:2:"{i";i:3;s:3:"0;s";i:4;s:1:"5";i:5;s:9:""en_US";i";i:6;s:3:"1;s";i:7;s:1:"5";i:8;s:9:""es_ES";i";i:9;s:3:"2;s";i:10;s:1:"5";i:11;s:9:""fr_CA";i";i:12;s:3:"3;s";i:13;s:1:"5";i:14;s:9:""pt_BR";}";i:15;s:5:"pt_PT";i:16;s:5:"pt_BR";i:17;s:5:"en_US";} | a:9:{i:0;s:1:"a";i:1;s:2:"{i";i:2;s:3:"0;s";i:3;s:1:"5";i:4;s:9:""en_US";i";i:5;s:3:"1;s";i:6;s:9:""pt_BR";}";i:7;s:5:"pt_BR";i:8;s:5:"en_US";} |
    +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+

Regards,

Renato L. Sousa

Hi @rensousa,

That’s definitely wrong. It should be a serialized PHP array containing the list of enabled locales, e.g.:

SELECT installed_locales, supported_locales FROM site;
+----------------------------------------+----------------------------------------+
| installed_locales                      | supported_locales                      |
+----------------------------------------+----------------------------------------+
| a:2:{i:0;s:5:"en_US";i:1;s:5:"fr_CA";} | a:2:{i:0;s:5:"en_US";i:1;s:5:"fr_CA";} |
+----------------------------------------+----------------------------------------+

As you see, this indicates that en_US and fr_CA are enabled. You can generate a string from the command line as follows:

php -r 'echo serialize(["en_US", "fr_CA"]) . "\n";'

Then put this in place instead of the garbled values you have. After you’ve made changes, make sure to flush your files cache (rm cache/*.php). And as always, take a good backup before changing values in your database manually.

Regards,
Alec Smecher
Public Knowledge Project Team