Array to string conversion in /var/www/emoncms/Modules/user/user_model.php

Had EmonCMS running good on Ubuntu 18 for a few months. Updated and now I am getting this error on the login page:

setcookie() expects parameter 3 to be integer, array given in /var/www/emoncms/Modules/user/rememberme_model.php

When I try to login, I now get:

Notice : Array to string conversion in /var/www/emoncms/Modules/user/user_model.php on line 164
false

Tried a fresh install of the STABLE branch and still got the Array to string error. Can it be that PHP was updated and emoncms still used the deprecated function?

temporarily commented out line 164

image

This allowed me to login successfully and view my feeds

PHP Version? - Weird case user 1 got corrupted somehow - #4 by TrystanLea

@TrystanLea

7.2.24

It was installed via install script.

Followed the upgrade script by @TrystanLea . Now im getting this error:

Uncaught Error: Class ‘Redis’ not found in /var/www/emoncms/index.php:36 Stack trace: #0 {main} thrown in /var/www/emoncms/index.php on line 36

Hello @ishtangli the latest version of emoncms requires php 7.4. You can either upgrade php and the other related dependencies following: Upgrading PHP version to 7.4 · Issue #1726 · emoncms/emoncms · GitHub or revert to emoncms version 10.7.4 for the time being if you want to look at this at a later point?

cd /var/www/emoncms
git checkout 10.7.4
1 Like

I followed the upgrade steps but still got an error:

Uncaught Error: Class ‘Redis’ not found in /var/www/emoncms/index.php:36 Stack trace: #0 {main} thrown in /var/www/emoncms/index.php on line 36

Tried again with a fresh install of Ubuntu 18.04 and using the install script immediately followed by the PHP upgrade process you described. Still getting the Class ‘Redis’ error.

Is there any way to force installation of PHP 7.4 using the install script?

Ok interesting, can you install using ubuntu 20.04 by any chance?
Looks like I need to look at this a bit closer, either by providing some backwards compatibility for php 7.2 or adding something to the script to force php 7.4 or later…

It sounds like something went wrong with the redis install and the client was either not installed correctly or not linked at the end correctly.

Perhaps try this again, do you see any errors?

sudo pecl -d php_suffix=7.4 install redis
printf "extension=redis.so" | sudo tee /etc/php/7.4/mods-available/redis.ini 1>&2
sudo phpenmod redis
sudo service apache2 restart

No errors. I’ve tried inputting those lines a few times with the same result.

ok, what do you get when you type:

php -v

and:

ls -lh /etc/php/7.4/apache2/conf.d/20-redis.ini

php -v

ls -lh /etc/php/7.4/apache2/conf.d/20-redis.ini

Thanks @ishtangli the first error suggests that redis.so has not installed correctly for php version 7.4, is there any chance that you could copy the last say 100 lines from the log result when you run:

sudo pecl -d php_suffix=7.4 install redis

Can you guide me to where I can find the log?

If you do this multiple times, will it just not add this line multiple times?

I didn’t pick that up from the release notes (behind on my updates). Does the upgrade script handle this?

From what version?

Sorry it is php 7.3 or more recent that is required, which in terms of emonSD version means emonSD-17Oct19 or newer. All emonSD images built using the EmonScripts install script are php7.3 or newer and so do not require the php update steps in the update script.

Older images pre 17Oct19 should no longer update automatically and so users should not see errors relating to this change after clicking update in the emoncms interface as the update should not proceed for those older images. A full image update is required instead.