Feeds stopped working after emoncms upgrade

Hi, I had the same problem after upgrading emoncms 8.4.0 to 9.9.5 and php 5.4 to 7.0.
I got similar errors in the error_log every time emoncms tried to process my energy impulses to power and kwh.
In Modules/process/process_model.php the line:
if (!($timezone === NULL)) $this->timezone = $timezone;
did not work (with php7?)
The fix was to change it to:
if (!isset($timezone)) $this->timezone = $timezone;

Hi @martmaiste, I split this as it looks like you might have found an issue.

Can I ask how long ago you found this?

@TrystanLea @glyn.hudson @Gwil, my PHP is no where near good enough to be able to comment. A quick check on the GitHub organisation shows this test is used a couple of times. Google did not throw it up as a known issue.

Hi, @borpin, about an hour before posting this. Just upgraded my emoncms and php version yesterday. I’m no php expert either, but php documentation says:
$a === $b Identical TRUE if $a is equal to $b, and they are of the same type.(PHP: Comparison Operators - Manual)
The special NULL value represents a variable with no value. NULL is the only possible value of type null.
Perhaps the type for $timezone is not null then.

Ok thanks. As I said my PHP isn’t good enough to know what the implications are. What led you to that solution?

Could you confirm the php version please?

The exact error message was:

PHP Fatal error:  Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (2) in /var/www/emoncms/Modules/process/process_processlist.php:1575
Stack trace:
#0 /var/www/emoncms/Modules/process/process_processlist.php(1575): DateTimeZone->__construct('2')
#1 /var/www/emoncms/Modules/process/process_processlist.php(1097): Process_ProcessList->getstartday(1548345861)
#2 /var/www/emoncms/Modules/process/process_model.php(71): Process_ProcessList->whinc_to_kwhd('42', 1548345861, 471, Array, Object(Process))
#3 /var/www/emoncms/Modules/process/process_model.php(122): Process->__call('whinc_to_kwhd', Array)
#4 /var/www/emoncms/Modules/input/input_methods.php(309): Process->input(1548345861, 471, '20:41,8:42', Array)
#5 /var/www/emoncms/Modules/input/input_methods.php(159): InputMethods->process_node('1', 1548345861, '13', Array)
#6 /var/www/emoncms/Modules/input/input_controller.php(51): InputMethods->post('1')
#7 /var/www/emoncms/core.php(64): input_controller()
#8 /var/www/emoncms/index.php(199): controller('input') in /var/www/emoncms/Modules/process/process_processlist.php on line 1575

It turned out, that on this line the $self->timezone value was empty. The same variable was used in process_model.php and did not get defined. I used lots of error_log($timezone) style for debugging. Also looked at the php documentation and tried another method (isset vs ===) and it worked.

php --version
PHP 7.0.33 (cli) (built: Jan  9 2019 14:57:19) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
1 Like

Excellent thanks. that will help :smile: