PHP7 issues with ZM API (due to bundled CakePHP 2.5-RC)

Forum for questions and support relating to the 1.29.x releases only.
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

PHP7 issues with ZM API (due to bundled CakePHP 2.5-RC)

Post by felixita »

(Original title was zmNinja error - Edited title to reflect true problem - this might start showing up for other users too - asker )

Hy, i'm using ZM 1.29 in my Arch linux. All work well, but i've a problem only with zm-ninja app. My Android App, but is the same for desktop version, fail streaming video. In zmninja app (or desktop) my credentials are verify. If i click on "system status" it show "Zoneminder is runnig" and i can see zm load. The problem appear if i make a click on Monitor or Events or Montage: a popup say to check credentials!.
I've googled for zm-ninja wiki and forum but i don't have found a solution. I've checked cgi-bin path and permission, but all seem alright. If i try to use another zm app like ZmView all work well and i can see all monitors and events.


Anyone can help me with zm-ninja? Below is a part of zm-ninja log file.

Thanks!

Code: Select all

version:1.0.7D

Feb 15, 2016 11:32:52 PM ERROR Monitor load failed {"success":false,"data":{"code":500,"name":"Cannot declare class CakeText, because the name is already in use","message":"Cannot declare class CakeText, because the name is already in use","url":"/zoneminder/api/monitors.json","exception":{"class":"FatalErrorException","code":500,"message":"Cannot declare class CakeText, because the name is already in use","trace":["#0 /srv/http/zoneminder/api/lib/Cake/Error/ErrorHandler.php(203): ErrorHandler::handleFatalError(64, 'Cannot declare ...', '/srv/http/zonem...', 25)","#1 /srv/http/zoneminder/api/lib/Cake/Core/App.php(929): ErrorHandler::handleError(64, 'Cannot declare ...', '/srv/http/zonem...', 25, Array)","#2 /srv/http/zoneminder/api/lib/Cake/Core/App.php(902): App::_checkFatalError()","#3 [internal function]: App::shutdown()","#4 {main}"]},"queryLog":{"default":{"log":[{"query":"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_API'    LIMIT 1","params":[],"affected":1,"numRows":1,"took":0},{"query":"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH'    LIMIT 1","params":[],"affected":1,"numRows":1,"took":0},{"query":"SELECT `User`.`Id`, `User`.`Username`, `User`.`Password`, `User`.`Language`, `User`.`Enabled`, `User`.`Stream`, `User`.`Events`, `User`.`Control`, `User`.`Monitors`, `User`.`Groups`, `User`.`Devices`, `User`.`System`, `User`.`MaxBandwidth`, `User`.`MonitorIds` FROM `zm`.`Users` AS `User`   WHERE `User`.`Username` = 'admin'    LIMIT 1","params":[],"affected":1,"numRows":1,"took":0},{"query":"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_API'    LIMIT 1","params":[],"affected":1,"numRows":1,"took":0},{"query":"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH'    LIMIT 1","params":[],"affected":1,"numRows":1,"took":0},{"query":"SELECT `User`.`Id`, `User`.`Username`, `User`.`Password`, `User`.`Language`, `User`.`Enabled`, `User`.`Stream`, `User`.`Events`, `User`.`Control`, `User`.`Monitors`, `User`.`Groups`, `User`.`Devices`, `User`.`System`, `User`.`MaxBandwidth`, `User`.`MonitorIds` FROM `zm`.`Users` AS `User`   WHERE `User`.`Username` = 'admin'    LIMIT 1","params":[],"affected":1,"numRows":1,"took":0}],"count":6,"time":0}}}}
Feb 15, 2016 11:32:52 PM INFO getMonitors:Loading all monitors
Feb 15, 2016 11:29:59 PM INFO ZM has recaptcha disabled - good
Feb 15, 2016 11:29:59 PM INFO Stream authentication construction: 
Feb 15, 2016 11:29:59 PM INFO Deferring auth key, as monitorId unknown
Feb 15, 2016 11:29:59 PM INFO zmAutologin successfully logged into Zoneminder
Feb 15, 2016 11:29:59 PM INFO Checking if reCaptcha is enabled in ZM...
Feb 15, 2016 11:29:59 PM INFO zmAutologin called
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm-ninja monitor error

Post by asker »

Hi there, please post zmNinja questions in the mobile forum (even if its the desktop port). This is only for ZM 1.29

Having said that, your post seems to indicate the problem is not with zmNinja - its with the APIs in ZM. So from that perspective, this post is fine to stay here.

Let's step back a bit and forget zmNinja:

1. Open up your ZM browser, login to the console
2. Open up another tab in the same browser and do a http://server/zm/api/monitors.json

what do you see?
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

Re: zm-ninja monitor error

Post by felixita »

if can be useful, my system have CakePHP 2.5.0-RC1 and php 7.0. Also i have attached my http://zoneminderip/api page.
Attachments
api.png
api.png (92.32 KiB) Viewed 34169 times
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm-ninja monitor error

Post by asker »

I think the problem is PHP 7. Please post the output of http://server/zm/api/monitors.json
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

Re: zm-ninja monitor error

Post by felixita »

i can see this in http://192.168.88.10/zoneminder/api/monitors.json

Code: Select all

{
    "success": false,
    "data": {
        "code": 500,
        "name": "Cannot declare class CakeText, because the name is already in use",
        "message": "Cannot declare class CakeText, because the name is already in use",
        "url": "\/zoneminder\/api\/monitors.json",
        "exception": {
            "class": "FatalErrorException",
            "code": 500,
            "message": "Cannot declare class CakeText, because the name is already in use",
            "trace": [
                "#0 \/srv\/http\/zoneminder\/api\/lib\/Cake\/Error\/ErrorHandler.php(203): ErrorHandler::handleFatalError(64, 'Cannot declare ...', '\/srv\/http\/zonem...', 25)",
                "#1 \/srv\/http\/zoneminder\/api\/lib\/Cake\/Core\/App.php(929): ErrorHandler::handleError(64, 'Cannot declare ...', '\/srv\/http\/zonem...', 25, Array)",
                "#2 \/srv\/http\/zoneminder\/api\/lib\/Cake\/Core\/App.php(902): App::_checkFatalError()",
                "#3 [internal function]: App::shutdown()",
                "#4 {main}"
            ]
        },
        "queryLog": {
            "default": {
                "log": [
                    {
                        "query": "SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_API'    LIMIT 1",
                        "params": [],
                        "affected": 1,
                        "numRows": 1,
                        "took": 0
                    },
                    {
                        "query": "SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH'    LIMIT 1",
                        "params": [],
                        "affected": 1,
                        "numRows": 1,
                        "took": 0
                    },
                    {
                        "query": "SELECT `User`.`Id`, `User`.`Username`, `User`.`Password`, `User`.`Language`, `User`.`Enabled`, `User`.`Stream`, `User`.`Events`, `User`.`Control`, `User`.`Monitors`, `User`.`Groups`, `User`.`Devices`, `User`.`System`, `User`.`MaxBandwidth`, `User`.`MonitorIds` FROM `zm`.`Users` AS `User`   WHERE `User`.`Username` = 'admin'    LIMIT 1",
                        "params": [],
                        "affected": 1,
                        "numRows": 1,
                        "took": 0
                    },
                    {
                        "query": "SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_API'    LIMIT 1",
                        "params": [],
                        "affected": 1,
                        "numRows": 1,
                        "took": 0
                    },
                    {
                        "query": "SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH'    LIMIT 1",
                        "params": [],
                        "affected": 1,
                        "numRows": 1,
                        "took": 0
                    },
                    {
                        "query": "SELECT `User`.`Id`, `User`.`Username`, `User`.`Password`, `User`.`Language`, `User`.`Enabled`, `User`.`Stream`, `User`.`Events`, `User`.`Control`, `User`.`Monitors`, `User`.`Groups`, `User`.`Devices`, `User`.`System`, `User`.`MaxBandwidth`, `User`.`MonitorIds` FROM `zm`.`Users` AS `User`   WHERE `User`.`Username` = 'admin'    LIMIT 1",
                        "params": [],
                        "affected": 1,
                        "numRows": 1,
                        "took": 0
                    }
                ],
                "count": 6,
                "time": 0
            }
        }
    }
}
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm-ninja monitor error

Post by asker »

Okay, so this confirms your problem is the APIs, not zmNinja - the APIs seem to be incompatible with PHP7. I see this "Cannot use X because the name is already in use" to be a common PHP 7 issue (see https://github.com/osTicket/osTicket-1.8/issues/2819 for example)

I don't have a solution right now - do you have another environment to deploy ZoneMinder what uses PHP 5.x?
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

Re: zm-ninja monitor error

Post by felixita »

Infact during installation i had used CakeText class instead of String in my zoneminder/api/lib/Cake/Utility/String.php (in accord with this https://github.com/cakephp/cakephp/issues/7573).

No, now i don't have other environment.

Thanks a lot, maybe an update will solve this issue.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm-ninja monitor error

Post by asker »

I'm not sure I understand. What exactly did you change when installing the APIs and why?
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm-ninja monitor error

Post by asker »

So it looks like ZM packages Cake 2.5 while PHP7 needs 2.8. the version that is packaged with ZM lies in www/api/lib
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

Re: zm-ninja monitor error

Post by felixita »

I've only substitute in zoneminder/api/lib/Cake/Utility/String.php:

Class String {....
with
Class CakeText {...
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm-ninja monitor error

Post by asker »

Okay, so I don't have a PHP7 environment, but give this a try (I don't know if it will work)

Code: Select all

cd /usr/share/zoneminder/api/lib
mv Cake Cake_old
git clone -b 2.x git://github.com/cakephp/cakephp.git
ln -s cakephp/lib/Cake/ .
Then try the API

If it doesn't work, we may have to upgrade the cakephp version using the upgrade tool
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

Re: PHP7 issues with ZM API (due to bundled CakePHP 2.5-RC)

Post by felixita »

i've tryed 2.8.0 but i got errors (view attachment of http://zoneminderaddress/api and http://zoneminderadress/api/monitors.json)
Attachments
monitor-1.png
monitor-1.png (71.36 KiB) Viewed 34110 times
2.8.0-2.png
2.8.0-2.png (126.14 KiB) Viewed 34110 times
2.8.0-1.png
2.8.0-1.png (129.71 KiB) Viewed 34110 times
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

Re: PHP7 issues with ZM API (due to bundled CakePHP 2.5-RC)

Post by felixita »

I've tried also with cakephp 2.7.8 installed by AUR repository but yet an error as you can see. Any ideas?
Attachments
cake_2.7.8_1.png
cake_2.7.8_1.png (71.71 KiB) Viewed 34096 times
cake_2.7.8.png
cake_2.7.8.png (124.26 KiB) Viewed 34096 times
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: PHP7 issues with ZM API (due to bundled CakePHP 2.5-RC)

Post by asker »

Are you familiar with using cakephp upgrade tool?
http://book.cakephp.org/3.0/en/upgrade-tool.html

I don't know how to use it - just throwing it out there - I need to get a PHP7 env
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
felixita
Posts: 28
Joined: Tue Feb 09, 2016 12:35 pm

Re: PHP7 issues with ZM API (due to bundled CakePHP 2.5-RC)

Post by felixita »

Ok, i've upgrade to cakephp 3.2 but... same problem: when i go to http://zmip/api i got a page which say:
Please change the value of 'Security.salt' in ROOT/config/app.php to a salt value specific to your application. [CORE/src/Error/Debugger.php, line 791].

I don't have enough experience to solve this. Maybe It has to do with secret encoding hashed authentication?
Attachments
cake_3.2.png
cake_3.2.png (53.59 KiB) Viewed 34053 times
Locked