Page 1 of 1

php7 error

Posted: Thu Aug 23, 2018 9:20 am
by sipi
I updated my zm from 1.30.2 to 1.30.4. I run it on openSuSE Leap 42.3 and use SUSE packages.

zm 1.30.2 used php5 and I haven't any problem, zmninja could connect to zm, cakephp worked fine. After update cakephp doesn't work me, zmninja can't connect to zm 1.30.4. zmninja message was "Login validated but API failed".

I get error messages in apache2's error.log:

[Wed Aug 22 22:03:19.833600 2018] [php7:error] [pid 11373] [client 192.168.1.2:55116] PHP Fatal error: Uncaught Error: Call to undefined function apc_fetch() in /srv/www/htdocs/zm/api/lib/Cake/Cache/Engine/ApcEngine.php:78\nStack trace:\n#0 /srv/www/htdocs/zm/api/lib/Cake/Cache/Cache.php(363): ApcEngine->read('myapp_cake_core...')\n#1 /srv/www/htdocs/zm/api/lib/Cake/I18n/I18n.php(235): Cache::read('cake_dev_hu', '_cake_core_')\n#2 /srv/www/htdocs/zm/api/lib/Cake/basics.php(636): I18n::translate('Cache engine "%...', NULL, 'cake_dev')\n#3 /srv/www/htdocs/zm/api/lib/Cake/Cache/Cache.php(184): __d('cake_dev', 'Cache engine "%...', '_cake_core_')\n#4 /srv/www/htdocs/zm/api/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_')\n#5 /srv/www/htdocs/zm/api/app/Config/core.php(375): Cache::config('_cake_core_', Array)\n#6 /srv/www/htdocs/zm/api/lib/Cake/Core/Configure.php(72): include('/srv/www/htdocs...')\n#7 /srv/www/htdocs/zm/api/lib/Cake/bootstrap.php(434): Configure::bootstrap(true)\n#8 /srv/www/htdocs/zm/api/app/webroot/index.php(90): include('/srv/www/htdocs...')\n#9 {main}\n thrown in /srv/www/htdocs/zm/api/lib/Cake/Cache/Engine/ApcEngine.php on line 78

I tried to test cakephp by http://serverip/zm/api/host/getVersion.json, http://serverip/zm/ap, http://serverip/zm/api/monitors.json but I get a blank page and same as error in apache2's error.log than zmninja connection.

I browsed this forum and all internet but I didn't find any solution. Can someone help me?

Re: php7 error

Posted: Thu Aug 23, 2018 11:07 pm
by bbunge
There was a similar issue with Ubuntu Bionic, 18.04, that was a result of PHP7.2 and some changes to cake and crud. I'm sure the issue was documented in this forum and the fixed thereto. I incorporated the changes in a repackaged Zoneminder 1.30.4 .deb install package which seem to be working for folks.

I have uploaded the api.fixed.tar.gz to Google Drive: https://drive.google.com/file/d/1QjvVeS ... sp=sharing

On Ubuntu the /api directory is located at: /usr/share/zoneminder/www Rename your existing /api directory and use the contents of the file listed. Should work...

Re: php7 error

Posted: Fri Aug 24, 2018 9:22 am
by sipi
Thank you bbunge, I downloaded api.fixed.tar.gz and I make what you recommend but API not work...

I checked http://serverip/zm/api/host/getVersion.json and the answer is "Could not open config file.".

I found this in apache2's error.log:
[Fri Aug 24 10:20:06.180750 2018] [php7:warn] [pid 18246] [client 192.168.1.2:57098] PHP Warning: file_put_contents(/var/log/zmerror.log) [<a href='http://php.net/function.file-put-conten ... ontents</a>]: failed to open stream: Permission denied in /srv/www/htdocs/zm/api/lib/Cake/Log/Engine/FileLog.php on line 142

suse used to log /srv/www/htdocs/zm/api/app/tmp/logs/error.log but this try to use /var/log/zmerror.log. Where is config for this?

I think there is some difference between ubuntu and suse package but I don't know what...

Have you any idea? Thanks.

Re: php7 error

Posted: Fri Aug 24, 2018 9:43 am
by sipi
Oh, I could solve it...

I found some difference between ubuntu and suse config... ubuntu release was loooking for /etc/zm/zm.conf but suse included it directly /etc/zm.conf.

I modified
Configure::write('ZM_CONFIG', '/etc/zm/zm.conf');
to
Configure::write('ZM_CONFIG', '/etc/zm.conf');
in /srv/www/htdocs/zm/api/app//Config/bootstrap.php line 115.

Then it works me...

Thanks you for your help.

Re: php7 error

Posted: Fri Aug 24, 2018 11:18 am
by sipi
It was too good...

After copied api.fixed.tar.gz and extracted it I need change new api dir owner to root:root recursively. And I need to delete tmp link and make some dirs under /srv/www/htdocs/zm/api/app and change owner

mkdir cache cache/models cache/persistent logs tmp tmp/logs
chown -R wwwrun:www cache cache/models cache/persistent logs tmp tmp/logs

Then zmninja works and http://serverip/zm/api/getVersion.json get a correct answer. I found when I run it make cake_error.log instead earlier error.log. And I found some error message in cake_error.log but zmninja works.

2018-08-24 12:26:26 Error: [MissingControllerException] Controller class GetVersionController could not be found.
Exception Attributes: array (
'class' => 'GetVersionController',
'plugin' => NULL,
)
Request URL: /zm/api/getVersion.json
Stack Trace:
#0 /srv/www/htdocs/zm/api/app/webroot/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
2018-08-24 12:26:26 Warning: Warning (2): file_put_contents(/var/log/zmerror.log): failed to open stream: Permission denied in [/srv/www/htdocs/zm/api/lib/Cake/Log/Engine/FileLog.php, line 142]
Trace:
ErrorHandler::handleError() - CORE/Cake/Error/ErrorHandler.php, line 230
file_put_contents - [internal], line ??
FileLog::write() - CORE/Cake/Log/Engine/FileLog.php, line 142
CakeLog::write() - CORE/Cake/Log/CakeLog.php, line 445
ErrorHandler::_log() - CORE/Cake/Error/ErrorHandler.php, line 188
ErrorHandler::handleException() - CORE/Cake/Error/ErrorHandler.php, line 118
[main] - [internal], line ??

I found an entry in bootstrap.php lines 110-114 what eliminated /var/zm/log error if I commented out it but Error: [MissingControllerException] Controller class GetVersionController could not be found still left there.

2018-08-24 12:35:14 Error: [MissingControllerException] Controller class GetVersionController could not be found.
Exception Attributes: array (
'class' => 'GetVersionController',
'plugin' => NULL,
)
Request URL: /zm/api/getVersion.json
Stack Trace:
#0 /srv/www/htdocs/zm/api/app/webroot/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}

I think the reason for this is the difference between ubuntu and suse but I can't solve this.

Do you have any idea?

Re: php7 error

Posted: Wed Aug 29, 2018 6:06 pm
by rockedge
there is a mistake somewhere in the API directory I think. I see the fix did not occur correctly for the API and the error shown is the exact error the broken API throws.

can you show what the /usr/share/zoneminder/www/api (or equivalent) looks like inside?
open /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Crud/CrudBaseObject.php (or equivalent) and look
for the line:

Code: Select all

abstract class CrudBaseObject extends Object implements CakeEventListener {
it should be :

Code: Select all

abstract class CrudBaseObject extends CakeObject implements CakeEventListener {
look here for more info : https://forums.zoneminder.com/viewtopi ... 92#p105092

Re: php7 error

Posted: Wed Sep 05, 2018 9:36 pm
by sipi
Hi,

I checked CrudBaseObject.php I found it correct same as what you recommend. Here

abstract class CrudBaseObject extends CakeObject implements CakeEventListener {

Other idea? Thanks.

Re: php7 error

Posted: Thu Sep 06, 2018 3:58 am
by rockedge
after another look at your log excerpts it looks like you're missing a php module!!

Code: Select all

PHP Fatal error: Uncaught Error: Call to undefined function apc_fetch()
you are missing the PHP modules php-apcu and php-apcu-bc
check phpinfo(); to see if these are installed!
If not go ahead and install those. they are not in PHP7+ by default.

Re: php7 error

Posted: Thu Sep 06, 2018 9:16 am
by sipi
php7-pecl-apcu-bc not installed because haven't suse package... I need a suse rpm package for this...

Thanks for your help.

Re: php7 error

Posted: Thu Sep 06, 2018 12:32 pm
by rockedge

Re: php7 error

Posted: Thu Sep 06, 2018 4:28 pm
by sipi
Thanks, yes, I know but there isn't php7-pecl-apcu-bc... There is only php7-apcu and I installed it from this repo. I don't understand why they have not done yet backward compatibility package...

Re: php7 error

Posted: Sat Sep 08, 2018 2:48 pm
by rockedge
I use Puppy Linux...several different versions which run ZM very nicely....I had to "borrow" the backwards compatible module from an RPM repo or from another Ubuntu version and stuffed it into the Ubuntu/debian based Puppy Linux OS's I use...which worked. The point being maybe you can use a package from some other distro.......