Cannot use a scalar as an array

More detailed debugging info shows:

Issue::setData(hideCoverPageArchives, 0, en_US): $this->_data[$key] is not array
PHP Warning:  Cannot use a scalar value as an array in ...

I think this is a bug in DataObject::setData(). Filing it…

Filed as [OJS] issue cover settings save inappropriate null-locale values, causing PHP scalar errors · Issue #1336 · pkp/pkp-lib · GitHub.

Hi,

I still have the same Problem after updating to OJS 3.0.2. Is there any solution to get rid of this warnings in the meanwhile?

Hi @Lydia_Mueller,

There are a couple of issues in this thread. Can you describe in detail?

Regards,
Alec Smecher
Public Knowledge Project Team

I mean the original issue. In the error log of my webserver running the OJS (3.0.2), I still have a lot warnings saying

PHP Warning: Cannot use a scalar value as an array in /var/www/html/ojs/lib/pkp/classes/core/DataObject.inc.php on line 133, referer:

Is there anything I can do to get rid of the warning?

Hi @Lydia_Mueller,

If you’re handy with PHP, try walking through the debugging steps earlier in this thread to identify which settings are causing the problems. If not, I’d suggest just ignoring the warnings for now.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
I upgrade without problems from version 2.4.8.1 to 3.0.2. After the upgrade version check the Usage stats, but it doesn’t work. it did the files and the ran the process but when I check the table metrics never update the stats. After that I need to check why is not upload. so, I set the php.ini with the error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED and the config.inc.php with [debug] show_stacktrace = On , display_errors = On, deprecation_warnings = On and log_web_service_info = On. after moved the file in the stage folder and I ran the next line php for OJS 3.0.2 /var/www/html/ojs/tools/runScheduledTasks.php /var/www/html/ojs/lib/pkp/plugins/generic/usageStats/scheduledTasks.xml
but the error show me

image

Can you help me how can solve this problem?, or how can check what is the real problem?.

Thanks in advance !!!

Hi @JCar,

The cause of this message is a mix of localized (locale column is set) and non-localized (locale column is empty or null) for a single setting_name, which is a data error. Follow some of the debugging suggestions here to find out what the setting_name in question is, then review the data in your database to see what it looks like.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
I checked all about your sugesstions in the special about the locale in the table issue_settings where I found some null value in the field locale, after fix it I check again the table issue_settings (select locale, Count(locale) from issue_settings group by locale;) and the result is:
image

I ran again the script /var/www/html/ojs/tools/runScheduledTasks.php /var/www/html/ojs/lib/pkp/plugins/generic/usageStats/scheduledTasks.xml but I have the same problem
image

Do you have idea what tables I need to check about the locale field or other fields?
Really I don’t understand whats is happen, because in the version 2.4.8.2 the statistics was working every day for the information update .

Can you help me?

Thanks in advance.

Hi @JCar,

There should be some entries with locale is null or locale = '' – it’ll depend on what setting_name (it doesn’t make sense to localize ISSNs, for example, but it does make sense to localize titles). The debugging procedures suggested on this issue will help to identify which specific setting_name has entries for both locale is null or locale = '' and locale is not null and locale <> '' for the same setting_name. That’ll be the key to debugging further.

If you’ve forced all rows to have a locale entry, then you’ll likely be causing more problems – I’d strongly suggest reverting this change.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
I revert the change. because I don’t have data with Null, I preferred reverting the change, Thanks for your suggestion. so, I have the same problem, how can I check what’s is the real mistake?

sorry @asmecher, Really I don’t undertand what is the correct form for check what is the posible problem…would can help me ?

Hi @JCar/all,

You can debug this by editing lib/pkp/classes/core/DataObject.inc.php, and finding line 133 or so, which should look like:

$this->_data[$key][$locale] = $value;

Just before this, add:

if (isset($this->_data[$key]) && !is_array($this->_data[$key])) error_log('Mixed localization for ' . get_class($this) . ', setting "' . $key . '"');

Then trigger the warning again (e.g. by reloading the page you saw it on before), and look in your log for more details.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hi @asmecher,
Thank you for your suggestions about the code. So now I know what is the problem I have more than one metacitations in one journal.
image

Can you suggest me how rows I need to delete or how can fix the problem. I tried delete the journal_id 13,14,15 than locale=’’, moved one log on folder stage and after ran the script /var/www/html/ojs/tools/runScheduledTasks.php /var/www/html/ojs/lib/pkp/plugins/generic/usageStats/scheduledTasks.xml …the task now not show me error, but the file isn’t upload in the table metrics. when I checked the error in the logs in apache show me

PHP Warning: array_merge(): Argument #2 is not an array in /var/www/html/ojs/lib/pkp/classes/core/PKPApplication.inc.php on line 578

can you help me what more steps I need to check for fix the upload the usages statistics ? the problem only is for upload, because the create of files is fine.

Hi @JCar,

You can safely delete all metaCitations rows from OJS 3.x – they’re a hold-over from OJS 2.x that is no longer useful. Execute:

 DELETE FROM journal_settings WHERE setting_name='metaCitations`;

Then remove all .php files from your cache/ subdirectory.

Regards,
Alec Smecher
Public Knowledge Project Team

3 Likes

Hi @asmecher,
thanks for the suggestions. I did the delete all rows than you told me and all php files from cache folder, after when I tried to upload the file not show me error and nothing…

image

I think is upload would be ok but when I tried to search in the metrics table in ojs, not import any rows from the file.

After ran the script for importations, the log file moves from the stage folder to archive folder. I checked in the folder scheduletasklogs the log from import, and it show me than the task had sucessful files import from the processing folder, so the files moved on the correct steps and folder, maybe the error is in mysql or other step, I don’t know.

I put on the warnings before the upload but not show me nothing. Really I don’t know what is happend with the import. where is the mistake ? how can I detect what is happening with the insert rows in the mysql?

thanks in advance !
Jonatan

Hi @JCar,

I think the DELETE should have resolved the original issue you reported in this thread, and the issue you’re describing now is something different. Could you post that as a new thread?

Thanks,
Alec Smecher
Public Knowledge Project Team

thank so much @asmecher, I fixed the problem. it was because I need to set the base_url[index] and the [journals] too, after it the upload files is sucessful. sorry about the mix of topics. Really thanks

hi
I have the same problem but ,this database did it already exist
thank you