[bug report] " WARNING: Cannot use a scalar value as an array" in "JournalSettingsDAO.inc.php"

I noticed that the following error is flooding the server log:

[04-Sep-2015 10:22:53 America/New_York] ojs2 has produced an error
  Message: WARNING: Cannot use a scalar value as an array
  In file: /home/user/public_html/ojs/classes/journal/JournalSettingsDAO.inc.php
  At line: 83
  Stacktrace: 
  Server info:
   OS: Linux
   PHP Version: 5.6.12
   Apache Version: N/A
   DB Driver: mysql
   DB server version: 5.5.32-cll-lve

the part of code for the error line is as follows:

    function &getJournalSettings($journalId) {
        $journalSettings = array();

        $result =& $this->retrieve(
            'SELECT setting_name, setting_value, setting_type, locale FROM journal_settings WHERE journal_id = ?', $journalId
        );

        while (!$result->EOF) {
            $row =& $result->getRowAssoc(false);
            $value = $this->convertFromDB($row['setting_value'], $row['setting_type']);
            if ($row['locale'] == '') {
                $journalSettings[$row['setting_name']] = $value;
            } else {
                if (!isset($journalSettings[$row['setting_name']])) {
                    $journalSettings[$row['setting_name']] = array();
                }
[line 83 --->]    $journalSettings[$row['setting_name']][$row['locale']] = $value;
            }
            $result->MoveNext();
        }
        $result->Close();
        unset($result);

        $cache =& $this->_getCache($journalId);
        $cache->setEntireCache($journalSettings);

        return $journalSettings;
    }

I am using ojs 2.4.5. and the only language (locale) for the journal is English.
Does upgrading to 2.4.6 resolves with issue?
Is there any patch for this bug?

thanks

Hi @Dani,

Have you reviewed other threads about this issue? See e.g. in the old forum:
http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=9523

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Excelent!!!

I had the same problem, and i reviewed the old forum and i did this:

  1. select * from journal_settings where setting_name like ‘metaCitations’
  2. Delete both metaCitations entries from your DB
  3. Flush the OJS data cache
  4. Go to Journal Setup step 3 and enable or disable the Citation Assistant as per your needs
  5. Save the form

this solve the problem.

So thanks!

2 Likes

Hi @cflores,

Great, glad to hear it’s working!

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hi @asmecher,
I checked the first step and the mysql result is

image

but really I don´t know what rows I need to have in the database of OJS. I’m user new in OJS. Can you help me ? thanks in advanced.

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

Which lines should I delete?

error-OJS

Hi @freddy,

In OJS 2.x, delete all rows with a value in the locale column. In OJS 3.x, it’s safe to delete them all – they’re not used any more.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

I appreciate your help, the error was corrected, I am sorry for the duplicate.

Please help in sorting out this error in my OJS 2.4.8
[28-Apr-2019 17:23:48 UTC] ojs2 has produced an error
Message: WARNING: Cannot use a scalar value as an array
In file: /home/kdlohtax/journals.eduindex.org/classes/journal/JournalSettingsDAO.inc.php
At line: 83
Stacktrace:
Server info:
OS: Linux
PHP Version: 5.6.40
Apache Version: N/A
DB Driver: mysql
DB server version: 10.2.23-MariaDB

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.

root@ojs-upgrade-2:/var/www/html/ojs-3.1.1-4/cache# rm *.php

Best regards,

Dung.

Hi @asmecher,

My problem is a little different.

SELECT DISTINCT s1.setting_name FROM journal_settings s1, journal_settings s2 WHERE s1.setting_name = s2.setting_name AND s1.locale = ‘’ AND s2.locale <> ‘’;

Return another setting_name besides metaCitations:

±--------------------+
| setting_name |
±--------------------+
| metaCitations |
| pageHeaderLogoImage |
±--------------------+

Aboute metaCitations,

select setting_name, setting_type, locale from journal_settings where setting_name like ‘metaCitations’;

shows me that…

±--------------±-------------±-------+
| setting_name | setting_type | locale |
±--------------±-------------±-------+
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | string | es_ES |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | en_US |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | es_ES |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | en_US |
| metaCitations | string | es_ES |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | es_ES |
| metaCitations | string | en_US |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | string | pt_BR |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
| metaCitations | bool | |
±--------------±-------------±-------+

I have to delete every column where setting_name like ‘metaCitations’ and setting_type = ‘string’.

But what about pageHeaderLogoImage?

select setting_name, setting_type, locale from journal_settings where setting_name like ‘pageHeaderLogoImage’;

which setting_type I have to delete?

±--------------------±-------------±-------+
| setting_name | setting_type | locale |
±--------------------±-------------±-------+
| pageHeaderLogoImage | object | |
| pageHeaderLogoImage | int | heigh |
| pageHeaderLogoImage | string | dateU |
| pageHeaderLogoImage | object | pt_BR |
| pageHeaderLogoImage | object | |
| pageHeaderLogoImage | string | name |
| pageHeaderLogoImage | string | uploa |
| pageHeaderLogoImage | object | |
| pageHeaderLogoImage | int | width |
| pageHeaderLogoImage | string | name |
| pageHeaderLogoImage | string | uploa |
| pageHeaderLogoImage | int | width |
| pageHeaderLogoImage | object | |
| pageHeaderLogoImage | object | |
| pageHeaderLogoImage | int | heigh |
| pageHeaderLogoImage | string | dateU |
| pageHeaderLogoImage | string | name |
| pageHeaderLogoImage | string | uploa |
| pageHeaderLogoImage | int | width |
| pageHeaderLogoImage | int | heigh |
| pageHeaderLogoImage | string | dateU |
| pageHeaderLogoImage | string | name |
| pageHeaderLogoImage | string | uploa |
| pageHeaderLogoImage | int | width |
| pageHeaderLogoImage | int | heigh |
| pageHeaderLogoImage | string | dateU |
| pageHeaderLogoImage | object | pt_BR |
| pageHeaderLogoImage | object | pt_BR |
| pageHeaderLogoImage | object | pt_BR |
| pageHeaderLogoImage | object | pt_BR |
| pageHeaderLogoImage | object | pt_BR |
| pageHeaderLogoImage | object | pt_BR |
±--------------------±-------------±-------+

Hi @tessiof,

For metaCitations:

I have to delete every column where setting_type = ‘string’.

No, don’t do that! Delete all rows where setting_name='metaCitations'.

But what about pageHeaderLogoImage?

What version of OJS are you using? Did you recently upgrade from another version?

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher

No, don’t do that! Delete all rows where setting_name='metaCitations' .

But I’m not supposed to delete from journal_settings where setting_name is ‘metaCitations’ and locale has a value? Locale has a value where setting_type is a string in this case, apparently. Sorry for not being very clear.

I’m using 2.4.8-5, updated from 2.4.8-2 one week ago. But this problem is older than that.

Hi @tessiof,

Ah, you’re using OJS 2.x still – I had assumed 3.x. Yes, DELETE FROM journal_settings WHERE setting_name = 'metaCitations' AND locale IS NOT NULL AND locale <> ''; and then flush your data cache (e.g. rm cache/*.php); that should do it.

For pageHeaderLogoImage, your data has somehow gotten corrupted – setting_type should be object, and locale should be e.g. xx_YY. If you don’t have too many journals you could simply delete that setting entirely (and flush the data cache), and then re-build it through the UI. (Make a backup before you work with the database directly, just in case.)

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

I managed to create a test site with those corrections, and the error messages vanished.
I’ll apply then in production next week.

Thanks!