(Solved) [ZM API] PHP Error

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
User avatar
R2D2
Posts: 170
Joined: Tue Dec 27, 2005 5:02 pm
Location: Stuttgart, Germany

(Solved) [ZM API] PHP Error

Post by R2D2 » Sat Jan 26, 2019 2:44 pm

Hi,

after a long time, i installed ZM again, but i cannot get working the ZM API. :(

When i type this in my Browser,

Code: Select all

http://server01/zm/api/
i get this:

Code: Select all

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 18
How can i solve this?
Last edited by R2D2 on Sat Feb 02, 2019 9:46 am, edited 1 time in total.

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

Re: [ZM API] PHP Error

Post by bbunge » Sat Jan 26, 2019 8:13 pm

Linux distro and version please...

User avatar
R2D2
Posts: 170
Joined: Tue Dec 27, 2005 5:02 pm
Location: Stuttgart, Germany

Re: [ZM API] PHP Error

Post by R2D2 » Sat Jan 26, 2019 8:27 pm

Distro is Gentoo
ZM is 1.32.3

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

Re: [ZM API] PHP Error

Post by rockedge » Sat Jan 26, 2019 11:40 pm

this looks like the CRUD and or the CakePHP components of the API are not the correct versions.

check these links out and see if your fix is in the mix.

viewtopic.php?p=105092#p105092

https://github.com/FriendsOfCake/crud/issues/581

User avatar
R2D2
Posts: 170
Joined: Tue Dec 27, 2005 5:02 pm
Location: Stuttgart, Germany

Re: [ZM API] PHP Error

Post by R2D2 » Sun Jan 27, 2019 8:29 am

After some "Experiments", now i get this issue:

Image

Code: Select all

Warning (2): Use of undefined constant ZM_OPT_USE_API - assumed 'ZM_OPT_USE_API' (this will throw an Error in a future version of PHP) [APP/Controller/AppController.php, line 63]

Warning (2): ini_set() [<a href='http://php.net/function.ini-set'>function.ini-set</a>]: Headers already sent. You cannot change the session module's ini settings at this time [CORE/Cake/Model/Datasource/CakeSession.php, line 581]

CakePHP: the rapid development php framework
Fatal Error

Error: require_once() [<a href='http://php.net/function.require'>function.require</a>]: Failed opening required '../../../includes/config.php' (include_path='.:/usr/share/php7:/usr/share/php')
File: /usr/share/zoneminder/www/api/app/Config/bootstrap.php
Line: 123

Notice: If you want to customize this error message, create app/View/Errors/fatal_error.ctp
CakePHP: the rapid development php framework	

CakePHP 2.10.8

Warning (2): Use of undefined constant ZM_DB_USER - assumed 'ZM_DB_USER' (this will throw an Error in a future version of PHP) [CORE/Cake/Model/ConnectionManager.php, line 69]

Warning (2): Use of undefined constant ZM_DB_PASS - assumed 'ZM_DB_PASS' (this will throw an Error in a future version of PHP) [CORE/Cake/Model/ConnectionManager.php, line 69]

Warning (2): Use of undefined constant ZM_DB_NAME - assumed 'ZM_DB_NAME' (this will throw an Error in a future version of PHP) [CORE/Cake/Model/ConnectionManager.php, line 69]

Warning (2): Use of undefined constant ZM_DB_SSL_CA_CERT - assumed 'ZM_DB_SSL_CA_CERT' (this will throw an Error in a future version of PHP) [CORE/Cake/Model/ConnectionManager.php, line 69]

Warning (2): Use of undefined constant ZM_DB_SSL_CLIENT_KEY - assumed 'ZM_DB_SSL_CLIENT_KEY' (this will throw an Error in a future version of PHP) [CORE/Cake/Model/ConnectionManager.php, line 69]

Warning (2): Use of undefined constant ZM_DB_SSL_CLIENT_CERT - assumed 'ZM_DB_SSL_CLIENT_CERT' (this will throw an Error in a future version of PHP) [CORE/Cake/Model/ConnectionManager.php, line 69]

Warning (2): Use of undefined constant ZM_DB_HOST - assumed 'ZM_DB_HOST' (this will throw an Error in a future version of PHP) [APP/Config/database.php, line 92]

Warning (2): Use of undefined constant ZM_DB_HOST - assumed 'ZM_DB_HOST' (this will throw an Error in a future version of PHP) [APP/Config/database.php, line 101]
BTW, i'am using PHP 7.1

Code: Select all

server01 ~ # php -v
PHP 7.1.26 (cli) (built: Jan 19 2019 12:09:17) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.26, Copyright (c) 1999-2018, by Zend Technologies
server01 ~ #

User avatar
R2D2
Posts: 170
Joined: Tue Dec 27, 2005 5:02 pm
Location: Stuttgart, Germany

Re: [ZM API] PHP Error

Post by R2D2 » Sun Jan 27, 2019 11:21 am

I edited the "/usr/share/zoneminder/www/api/app/Config/bootstrap.php" from,

Code: Select all

require_once("../../../includes/config.php");
to

Code: Select all

require_once("/usr/share/zoneminder/www/includes/config.php")
but now i get the following issue:

Code: Select all

Uncaught FatalErrorException: [MissingPluginException] Plugin Crud could not be found. 
#0 /usr/share/zoneminder/www/api/lib/Cake/Core/App.php(227): CakePlugin::path('Crud') 
#1 /usr/share/zoneminder/www/api/lib/Cake/Core/App.php(549): App::path('Lib', 'Crud') 
#2 [internal function]: App::load('CrudControllerT...') 
#3 /usr/share/zoneminder/www/api/app/Controller/AppController.php(34): spl_autoload_call('CrudControllerT...') 
#4 /usr/share/zoneminder/www/api/lib/Cake/Core/App.php(547): include('/usr/share/zone...') 
#5 [internal function]: App::load('AppController') 
#6 [internal function]: spl_autoload_call('AppController') 
#7 /usr/share/zoneminder/www/api/lib/Cake/Error/ExceptionRenderer.php(155): class_exists('AppController') 
#8 /usr/share/zoneminder/www/api/lib/Cake/Error/ExceptionRenderer.php(95): ExceptionRenderer->_getController(Object(ParseError)) 
#9 /usr/share/zoneminder/www/api/lib/Cake/Error/ErrorHandler.php(126): ExceptionRenderer->__construct(Object(ParseError)) 
#10 [internal function]: ErrorHandler::h

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

Re: [ZM API] PHP Error

Post by rockedge » Tue Jan 29, 2019 3:48 am

you must identify which version of CakePHP and CRUD you have in your ZM setup.

change what you done back to it's original code. go look in /usr/share/zoneminder/www/api/app/Plugin/Crud/README.md
(or the path to your ZM installation) At the top of this file it should have :

Code: Select all

# Version notice

This version of Crud is for CakePHP 2.x.
This fork has been patched for PHP 7.2 compatibilty, specifically for the [ZoneMinder](https://github.com/ZoneMinder/ZoneMinder) project. 
This fork will no longer be necessary once [Pull Reqeust #282](https://github.com/FriendsOfCake/crud/pull/582) has been merged.
if not, you might have the version CRUD and CakePHP that isn't fixed to work with PHP 7.2+

the correct versions are here at this link and can be swapped in manually with relative ease.

User avatar
R2D2
Posts: 170
Joined: Tue Dec 27, 2005 5:02 pm
Location: Stuttgart, Germany

Re: [ZM API] PHP Error

Post by R2D2 » Tue Jan 29, 2019 6:47 pm

OK, reverted all, an did the instructions from your link above.

But now i get this issue:

Code: Select all

Fatal error: Uncaught FatalErrorException: [CakeSessionException] Unable to configure the session, setting session.use_trans_sid failed. 
#0 /usr/share/zoneminder/www/api/lib/Cake/Model/Datasource/CakeSession.php(732): CakeSession::_configureSession() 
#1 /usr/share/zoneminder/www/api/lib/Cake/Model/Datasource/CakeSession.php(219): CakeSession::_startSession() 
#2 /usr/share/zoneminder/www/api/lib/Cake/Model/Datasource/CakeSession.php(248): CakeSession::start() 
#3 /usr/share/zoneminder/www/api/lib/Cake/View/Helper/SessionHelper.php(134): CakeSession::check('Message.flash') 
#4 /usr/share/zoneminder/www/api/app/View/Layouts/error.ctp(46): SessionHelper->flash() 
#5 /usr/share/zoneminder/www/api/lib/Cake/View/View.php(971): include('/usr/share/zone...') 
#6 /usr/share/zoneminder/www/api/lib/Cake/View/View.php(933): View->_evaluate('/usr/share/zone...', Array) 
#7 /usr/share/zoneminder/www/api/lib/Cake/View/View.php(546): View->_render('/usr/share/zone...') 
#8 /usr/share/zoneminder/www/api/lib/Cake/View/View.php(481): View->renderL in /usr/share/zoneminder/www/api/lib/Cake/Error/ErrorHandler.php on line 138

User avatar
R2D2
Posts: 170
Joined: Tue Dec 27, 2005 5:02 pm
Location: Stuttgart, Germany

Re: [ZM API] PHP Error

Post by R2D2 » Sat Feb 02, 2019 9:45 am

SOLVED!

I found this in the gentoo Forum:

https://forums.gentoo.org/viewtopic-p-8 ... ml#8293346

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

Re: (Solved) [ZM API] PHP Error

Post by rockedge » Sat Feb 02, 2019 2:37 pm

yes I was hoping the links I listed had this information...great that you have it going! Good work.

rayrayray
Posts: 14
Joined: Sun Apr 25, 2010 10:59 pm

Re: (Solved) [ZM API] PHP Error

Post by rayrayray » Tue Feb 12, 2019 4:20 pm

Thank you! I was struggling with the same API error with Ubuntu 18.04.01 LTS and 1.32.3. I didn't need any of the code changes in that forum post -- the code fix and CakePHP plugin files were already present on my system. I only needed these updates to my Apache2 config:

Code: Select all

# For better visibility, the following directives have been migrated from the
# default .htaccess files included with the CakePHP project.
# Parameters not set here are inherited from the parent directive above.
<Directory "/usr/share/zoneminder/www/api">
   RewriteEngine on
   RewriteRule ^$ app/webroot/ [L]
   RewriteRule (.*) app/webroot/$1 [L]
   RewriteBase /zm/api
</Directory>

<Directory "/usr/share/zoneminder/www/api/app">
   RewriteEngine on
   RewriteRule ^$ webroot/ [L]
   RewriteRule (.*) webroot/$1 [L]
   RewriteBase /zm/api
</Directory>

<Directory "/usr/share/zoneminder/www/api/app/webroot">
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteBase /zm/api
</Directory> 
You spoony bard!

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests