(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: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

the /api/app folder contains the files needed for the ZM API and the /api/lib is the cakephp system that one can swap out different versions......theoretically
The Crud plugin goes into /api/app/Plugin/Crud
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

I got the API to work somewhat.......very promising the return gave me

Code: Select all

{
    "code": 500,
    "name": "Class 'AppController' not found",
    "message": "Class 'AppController' not found",
    "url": "\/zm\/api\/host\/getVersion.json"
}
api_working.png
api_working.png (174.7 KiB) Viewed 24766 times
api_result.png
api_result.png (71.62 KiB) Viewed 24766 times
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

Using cakephp 2.10.8 and Crud 3.0.10 ( the first version compatible with PHP 7 +) there are a lot of little shortcuts and temp modifications like lines being added and others commented out....as soon as I hammer out this last hurdle of an error(s) I will have to clean it up and try to duplicate it so I can actually add the fix in a less chaotic way....there are all kinds of odd mixing going on but it almost works again.
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

except for a nagging minor error I have the API running....somewhat!
api_working_success.png
api_working_success.png (78.85 KiB) Viewed 24763 times
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

finally......now to document what actually happened....
zmNinja running with ZM 1.31.1 in PHP 7.2
api-ninja-test.png
api-ninja-test.png (281.92 KiB) Viewed 24761 times
bbunge
Posts: 2930
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: API not working with PHP 7.2

Post by bbunge »

Great! But I will have to shovel out a foot of snow before computer work!
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

the snow is just starting to fall here....oh no...shovels ready but it may be snowblower time...2nd day of spring and the 4th storm in 4 weeks.....on the beach metal detecting I want to go...but ya can't go surfin' when it's 20 below

the fix seems to easy to do now that I am looking at what really needed to be modified.....and tested Hiawatha and ZM works well and the API also working nicely.
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

I just tested the API in iconner's zoneminder-storageareas 1.31.39 by deleting the /usr/share/zoneminder/www/api folder and replacing it with the one from the working version 1.31.1 master ..... and it works.

now I will document the fix and further test by upgrading the cakephp and Crud components as far up as they will go and still work as expected.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: API not working with PHP 7.2

Post by knight-of-ni »

Sometimes I think I'm dyslexic... Until just now, I didn't notice there is a Crud 3.1.0 release, which is not to be confused with the 3.0.10 version we use currently. 3.1.0 is compatible with Cakephp 2.x, and it has fixes in it directly related to php 7.2 compatibility. Can you guys try that?
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: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

yes I will test it where is 3.1.0 to download?

Here it is -> https://github.com/FriendsOfCake/crud/r ... fter=5.1.1
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: API not working with PHP 7.2

Post by rockedge »

Okay Crud 3.1.0 works..... here is what I did:
Starting with a stock zoneminder 1.31.+
Download the cakephp-2.10.8.zip and extract the contents
1. using the cakephp 2.10.8 folder overwrite the /lib folder in /usr/share/zoneminder/www/api
2. using Crud 3.1.0.zip swap the contents of the file into /usr/share/zoneminder/www/api/app/Plugin/Crud
(change the permissions of the folders to the web server user)
3. open /usr/share/zoneminder/www/api/app/Plugin/Crud/Controller/Crud/CrudeBaseObject.php and change around line 15

Code: Select all

abstract class CrudBaseObject extends Object implements CakeEventListener {
to

Code: Select all

abstract class CrudBaseObject extends CakeObject implements CakeEventListener {
the API should work as expected.
the links are:
Crud 3.1.0 :https://github.com/FriendsOfCake/crud/r ... tag/v3.1.0
cakephp 2.10.8 :https://github.com/cakephp/cakephp/arch ... 0.8.tar.gz
Last edited by rockedge on Thu Mar 22, 2018 11:52 pm, edited 4 times in total.
bbunge
Posts: 2930
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

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

Post by bbunge »

YAHOO!!!
Works on Ubuntu 18.04, MySQL, Zoneminder 1.30.4. Tested with ZMNINJA as well as the api/host/getVersion.json

I used the install procedure from Ubuntu 17.10 on the WIKI with a manual download of amd64 ppa Zesty install.

Have to finish cleaning out snow, about 15 inches today, then will try to package this to do an install from a .deb.

Thanks all!!!
bbunge
Posts: 2930
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

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

Post by bbunge »

Repackaged amd64 .deb for Zesty ZM 1.30.4 with the API fixes. Installed on Ubuntu 18.04 server with Mariadb and MySQL per WIKI instructions here with a couple of exceptions: https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way

Link to install package: https://drive.google.com/file/d/1pxpUTb ... sp=sharing

Download and copy install package zoneminder-bionic-amd64.deb to your home directory. (could not get wget to work with Google Drive)

When editing the php.ini use 7.2 instead if 7.1
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

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

Post by knight-of-ni »

Can you guys check something for me....

I had a moment to install 18.04, and I can get the api working by changing just the abstract class to mention CakeObject, rather than Object.
The api appears to still work if I skip adding App::uses('AppController', 'Controller');

Can you confirm this?
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: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post by rockedge »

I tested it out with Bionic 18.04 PHP 7.2.3 ZM 1.31.1 and does seem to work with out the line

Code: Select all

App::uses('AppController', 'Controller');
good deal. I will test it again with ZM 1.31.39 and 1.30.4 but it should be the same. I think I stuck it in there while debugging....
Locked