(Solved)API not working with PHP 7.2 and Bionic 18.04

Forum for questions and support relating to the 1.31.x releases only.
rockedge
Posts: 1114
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA
Contact:

(Solved)API not working with PHP 7.2 and Bionic 18.04

Post by rockedge » Wed Mar 14, 2018 5:19 pm

Installed ZM 1.31.39 on a Puppy Linux Bionic (Ubuntu 18.04 binaries and is compatible)
Hiawatha 10.7
PHP 7.2
mariadb
and ZM is working mostly. The API is failing due to Cakewalk having a name defintion of objects problem due to changes in definitions with PHP 7.2
an example of the errors. Using /zm-server/zm/api/host/getVersion.json returns nothing but a blank page.

Code: Select all

192.168.0.6|Tue 13 Mar 2018 18:09:01 -0400|/usr/share/zoneminder/www/api/app/webroot/index.php|PHP Fatal error:  Cannot use 'Object' as class name as it is reserved in /usr/share/zoneminder/www/api/lib/Cake/Core/Object.php on line 30
192.168.0.6|Tue 13 Mar 2018 18:09:01 -0400|/usr/share/zoneminder/www/api/app/webroot/index.php|PHP Fatal error:  Class 'Object' not found in /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php on line 58
192.168.0.6|Tue 13 Mar 2018 18:09:01 -0400|/usr/share/zoneminder/www/api/app/webroot/index.php|CGI returned 500 Internal Error
So the changes in PHP 7.2 cause the API not to work.
Last edited by rockedge on Wed Mar 21, 2018 9:25 pm, edited 2 times in total.

bbunge
Posts: 2446
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working with PHP 7.2

Post by bbunge » Wed Mar 14, 2018 9:06 pm

Same problem with Ubuntu-Server 18.04 installing the .deb per the WIKI install for 17.10. Have successfully upgraded Ubuntu 16.04 with ZM 1.30.4 to Ubuntu-Server development version 18.04 and everything, including API, worked. Am in process of doing it again to get the steps I did written down. Stay tuned...

BTW - Zoneminder has been removed from Ubuntu 18.04.

User avatar
knight-of-ni
Posts: 2231
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: API not working with PHP 7.2

Post by knight-of-ni » Wed Mar 14, 2018 10:09 pm

Ah, yep. This appears to be affecting multiple projects:
https://www.google.com/search?q=PHP+Fat ... e&ie=UTF-8

The knee-jerk fix would be to simply change the name of the object to something else, but perhaps we ought to look into what it would take to upgrade the version of cakephp instead. That of course, could be more work that it's worth, but It is worth looking into.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

User avatar
knight-of-ni
Posts: 2231
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: API not working with PHP 7.2

Post by knight-of-ni » Wed Mar 14, 2018 11:17 pm

So this turns out to be a known issue with cakephp 2.x versions which was fixed in 2.10.7:
https://github.com/cakephp/cakephp/releases/tag/2.10.7
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

rockedge
Posts: 1114
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA
Contact:

Re: API not working with PHP 7.2

Post by rockedge » Thu Mar 15, 2018 2:06 pm

I replaced the cakephp version to 2.10.7. Then taking some of the controllers code and moving some stuff back and forth to the point of who knows what I did....I have reached a point where only 1 error is appearing and at least something is showing after entering /zm-server/zm/api/host/getVersion.json....

Code: Select all

Fatal error: Class 'CakeObject' not found in /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php on line 58

bbunge
Posts: 2446
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working with PHP 7.2

Post by bbunge » Thu Mar 15, 2018 8:09 pm

Have upgraded to Cakephp 2.10.7 and can get 1.30.4 and 1.31.1 to work on Ubuntu server 18.04 (dtd 15MAR18) but no luck with the API.

Must be the doom of The Ides of March...

rockedge
Posts: 1114
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA
Contact:

Re: API not working with PHP 7.2

Post by rockedge » Fri Mar 16, 2018 3:29 pm

I have the same....both 1.30.4 and 1.31.39 working.....mostly working on Puppy Linux Bionic (18.04) PHP 7.2....but the API refuses to be fixed... I have it to the point where cakephp was displaying a page but still named some (warnings) errors...I felt really close to getting it going then one more small modification and back to square 1..... but I am still going at it ... the page displaying was a start and looked good...I will see if I can get back there again.

bbunge
Posts: 2446
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working with PHP 7.2

Post by bbunge » Fri Mar 16, 2018 5:18 pm

After a morning of retail therapy am updating my Ubuntu 18.04 images. Noticed PHP7.2 got some upgrades today.
Found a copy of zoneminder_1.30.4+dfsg-2_amd64.deb which may be the version that was on the earlier 18.04. Plan to try to install that. Have had problems getting the 1.31.1 from the PPA master to finish installing and will not create database.

bbunge
Posts: 2446
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working with PHP 7.2

Post by bbunge » Sat Mar 17, 2018 12:14 am

With CakePHP 2.10.7 installed in /var/www/html/cake and no errors showing on the cake test screen I've repackaged zoneminder_1.30.4+dfsg-2_amd64.deb and removed the requirement for cakephp and zoneminder-docs.
Installed php-gd and ffmpeg with apt before installing repackaged zoneminder with apt.
Followed my interim procedure on the WIKI except used php7.2: https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way
Zoneminder runs and captures events. Still no api when tested. Did notice a file generated called '/etc/zm/core.php' Checked through it to see if there was a setting to point to my cake install. Np luck....yet

Suggestions?

User avatar
knight-of-ni
Posts: 2231
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: API not working with PHP 7.2

Post by knight-of-ni » Sat Mar 17, 2018 1:29 pm

hmmmm..... /etc/zm/core.php - that doesn't look like its in the right place. Unless someone has made a change I am not aware of, there should only be *.conf files there.

In order for ZoneMinder to work with the version of cakephp we have currently, certain files had to be modified by us. If I recall, all these files live here: https://github.com/ZoneMinder/zoneminde ... app/Config

So for anyone who is attempting to upgrade the version of cakephp on their system, the first thing that comes to mind is whether you took the zoneminder specific information out of those files and properly blended them into the new files. It is entirely possible that certain variable names have changed too.

Our cakephp folder also has several .htaccess files hidden in several places. You need to make sure those are still there, and in the right spot. On a side note, I have gotten rid of these sneaky files for redhat builds and have chosen to centralize this into the master apache config file. Look here: https://github.com/ZoneMinder/zoneminde ... onf.in#L47

The folder names in each apache directive tell you where to look for the .htaccess files. If this turns out to be the issue, perhaps this would be a good time to centralize these for debian builds too.

If you have already done these steps, then the next thing we need is data. I don't know what you mean when you say "no api". What do you see when you manually type in an api url into your browser? Blank screen? http 404? Also, there is a cake error log. Have you looked at that? The location of the errorlog is one of the things we modified. Depending on the state of you system at the moment, the cake errorlog might be under /var/log/zoneminder. in zoneminder's temp folder, or the cakephp tmp folder. If the commands are indeed getting to cakephp, then it is most certainly writing error messages to that file.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

rockedge
Posts: 1114
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA
Contact:

Re: API not working with PHP 7.2

Post by rockedge » Sat Mar 17, 2018 2:35 pm

I started fresh with Bionic 18.04 and installed Hiawatha 10.7 PHP 7.2 mariadb zoneminder 1.31.39 (storageareas).
ZM runs and streams also will detect motion and create events which can be viewed. Some other small things I noticed with video and export are so-so but that comes another time.
I am using now cakephp 2.10.7 with crud-c3976f1478c681b0bbc132ec3a3e82c3984eeed5. and I did also get a cakephp page but some warnings.Now after some more modification this is what I am running into

Code: Select all

Fatal error: Uncaught Error: Class 'RelatedModelsListener' not found in /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Component/CrudComponent.php:752
Stack trace: 
#0 /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Component/CrudComponent.php(728): CrudComponent->_loadListener('RelatedModels') 
#1 /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Component/CrudComponent.php(169):
CrudComponent->_loadListeners()
#2 /usr/share/zoneminder/www/api/lib/Cake/Utility/ObjectCollection.php(128):
 CrudComponent->initialize(Object(CakeErrorController)) 
#3 /usr/share/zoneminder/www/api/lib/Cake/Event/CakeEventManager.php(243):
  ObjectCollection->trigger('initialize') 
#4 /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php(677):
   CakeEventManager->dispatch(Object(CakeEvent)) 
#5 /usr/share/zoneminder/www/api/lib/Cake/Error/ExceptionRenderer.php(158):
    Controller->startupProcess() 
#6 /usr/share/zoneminder/www/api/lib/Cake/Error/ExceptionRenderer.php(95):
     ExceptionRenderer->_getController(Object(FatalErro in /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Component/CrudComponent.php on line 752
I also tried cakephp 3.5.13 and crud-master to see what happened... same errors. I am adding the /api/apps/Controllers content from a working API from Artful 17.10 ZM install which I got the API to work.
Also adding the /api/apps/Models content from the same source.

bbunge
Posts: 2446
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working with PHP 7.2

Post by bbunge » Sat Mar 17, 2018 3:27 pm


rockedge
Posts: 1114
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA
Contact:

Re: API not working with PHP 7.2

Post by rockedge » Sat Mar 17, 2018 4:25 pm

are you seeing in the error.log this? ->

Code: Select all

Fatal error: Class 'CakeObject' not found in /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php on line 58
the Class 'RelatedModelsListener' not found error above I fixed sometime yesterday but for the life of me I can not remember what I did but I got past this and received a cakePHP error page with some warnings of undefined zoneminder config variables

rockedge
Posts: 1114
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA
Contact:

Re: API not working with PHP 7.2

Post by rockedge » Sat Mar 17, 2018 6:16 pm

this is the stage before adding the controllers and models
api_error1.png
api_error1.png (101.58 KiB) Viewed 4501 times
and this error after copying the /app/Controllers and /app/Models from a working API in a ZM 1.31.39 Artful 17.10

Code: Select all

Fatal error: Class 'Cake\Controller\Component' not found in /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Component/CrudComponent.php on line 25

rockedge
Posts: 1114
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA
Contact:

Re: API not working with PHP 7.2

Post by rockedge » Sat Mar 17, 2018 6:30 pm

and now :

Code: Select all

127.0.0.1|Sat 17 Mar 2018 14:28:11 -0400|/usr/share/zoneminder/www/api/app/webroot/index.php|PHP Fatal error:  Trait 'CrudControllerTrait' not found in /usr/share/zoneminder/www/api/app/Controller/AppController.php on line 34

127.0.0.1|Sat 17 Mar 2018 14:28:11 -0400|/usr/share/zoneminder/www/api/app/webroot/index.php|PHP Fatal error:  Class 'Cake\Controller\Component' not found in /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Component/CrudComponent.php on line 25

127.0.0.1|Sat 17 Mar 2018 14:28:11 -0400|/usr/share/zoneminder/www/api/app/webroot/index.php|CGI returned 500 Internal Error

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests