ZoneMinder / zoneminder

ZoneMinder is a free, open source Closed-circuit television software application developed for Linux which supports IP, USB and Analog cameras.
http://www.zoneminder.com/
GNU General Public License v2.0
5.13k stars 1.22k forks source link

White screen and Undefined constant "ZM\ZM_LOG_LEVEL_DATABASE" after recent update #3427

Closed calvss closed 7 months ago

calvss commented 2 years ago

Describe Your Environment

Describe the bug I'm getting a white screen on the web interface after a recent update, and enabling display_errors in php gets me this error message: Fatal error: Uncaught Error: Undefined constant "ZM\ZM_LOG_LEVEL_DATABASE" in /usr/share/zoneminder/www/includes/logger.php:102 Stack trace: #0 /usr/share/zoneminder/www/includes/logger.php(197): ZM\Logger->initialise() #1 /usr/share/zoneminder/www/includes/config.php(141): ZM\Logger::fetch() #2 /usr/share/zoneminder/www/index.php(46): require_once('...') #3 {main} thrown in /usr/share/zoneminder/www/includes/logger.php on line 102

To Reproduce Steps to reproduce the behavior:

  1. Have a working setup before 1.36.12
  2. # apt update && apt upgrade
  3. Open browser
  4. White screen

Expected behavior Not a white screen

Debug Logs systemctl status zoneminder doesn't print any errors based on the php error, I guess it isn't logging anything correctly?

welcome[bot] commented 2 years ago

Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!

bachmarc commented 2 years ago

Just to double it, I have same issue with fresh Debian Testing build of this week. No DB "zm" was created during apt install and no user "zmuser" I did manually, service starts fine afterwards but calling the main page ends in 500 and log shows: PHP Fatal error: Uncaught Error: Undefined constant "ZM\\ZM_LOG_LEVEL_DATABASE" in /usr/share/zoneminder/www/includes/logger.php:102\nStack trace:\n#0 /usr/share/zoneminder/www/includes/logger.php(197): ZM\\Logger->initialise()\n#1 /usr/share/zoneminder/www/includes/config.php(141): ZM\\Logger::fetch()\n#2 /usr/share/zoneminder/www/index.php(46): require_once('...')\n#3 {main}\n thrown in /usr/share/zoneminder/www/includes/logger.php on line 102

onlyjob commented 2 years ago

What gave you the idea that database should be created for you automatically?? MariaDB might be running on a different server and it is up to admin to know/plan the setup and to implement it. Not everything is worth automating and instructions on how to initialise database are simple enough. You should have checked the README and the documentation. Some documentation is provided by the package and other is available here: https://zoneminder.readthedocs.io/en/stable/

bachmarc commented 2 years ago

There is no current installation guide for Debian 11. The available guides for older releases differ and the "Stretch" one is not including the DB step. I have no problems with deploying a DB but a chapter that mentions it, and points to the sql-dump of the DB helps. I obviously managed to get the puzzle solved from a lot of different pages till the services started.

Now I get an error from Logger that a constant is not defined. As nothing is documented in detail its quite challenging to get a step further without debugging. I reached a point that 99% never see because they give up before. I will not start a debugger to find out where this constant should come from or why no parameter are delivered to avoid the fallback to constant.

I know you are doing this as a volunteer, therefore its up to you if this is fine for you or not. I just offered to help and tried to do more than the 99% that simply use a different distro Marc

onlyjob commented 2 years ago

There is no current installation guide for Debian 11.

So you've never checked README (and other files) in /usr/share/doc/zoneminder ??

Please let me know if the following README is missing anything (or in need of any corrections): https://sources.debian.org/src/zoneminder/1.36.14%2Bdfsg1-1/debian/README.Debian/ Your improvement suggestions will be most welcome. (README.Debian is maintained here: https://salsa.debian.org/debian/zoneminder/-/blob/master/debian/README.Debian)

connortechnology commented 2 years ago

The wiki is a mess. Every debian based install guide should start with a pointer to the README.

bachmarc commented 2 years ago

There is no current installation guide for Debian 11.

So you've never checked README (and other files) in /usr/share/doc/zoneminder ??

Please let me know if the following README is missing anything (or in need of any corrections): https://sources.debian.org/src/zoneminder/1.36.14%2Bdfsg1-1/debian/README.Debian/ Your improvement suggestions will be most welcome. (README.Debian is maintained here: https://salsa.debian.org/debian/zoneminder/-/blob/master/debian/README.Debian)

HI, to be frank: no Usually I read through the installation guide to estimate the effort and challenges... I found no current but several very similar older guides. One mentioned DB installation, one said it is done "magically" starting with a certain release, one pointed to a sql dump.

So I decided to run apt-get install zoneminder and see what happens. It ran, installed some dependencies (DB ...) and exited with a clean 0. I think to remember that some debian packages inform about open tasks, I do not recall that zoneminder did it.

No think to have created the DB correctly, I read the README , the service is starting BUT hostnome/zm gives a 500... I am not sure what went wrong or how to fix it. So reading the README was not an eye opener.. somehow it was like a mixture of the other guides read.

When I get it up and runnig I will consolidate my findings in guide 5 /readme

Marc

nabbi commented 2 years ago

I also seen this symptom if the zm_create.sql import failed at reading the triggers.sql, resulting in a partial configuration. DROP the tables and start over.

SergRuPV commented 2 years ago

Hi! I had this the bug. You need check your database, table Config.

You need follow next commands in the MySQL MySQL [(none)]> use zm MySQL [zm]> SELECT * FROM Config WHERE Id=59;

The correct result:

| Id | Name | Value | Type | DefaultValue | Hint | Pattern | Format | Prompt | Help | Category | Readonly | Private | System | Requires |

| 59 | ZM_LOG_LEVEL_DATABASE | 0 | integer | 0 | None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1 | (?^:^(d+)$) | $1 | Save logging output to the database | ZoneMinder logging is now more integrated between components and allows you to specify the destination for logging output and the individual levels for each. This option lets you control the level of logging output that is written to the database. This is a new option which can make viewing logging output easier and more intuitive and also makes it easier to get an overall impression of how the system is performing. If you have a large or very busy system then it is possible that use of this option may slow your system down if the table becomes very large. Ensure you use the LOG_DATABASE_LIMIT option to keep the table to a manageable size. This option controls the maximum level of logging that will be written, so Info includes Warnings and Errors etc. To disable entirely, set this option to None. You should use caution when setting this option to Debug as it can affect severely affect system performance. If you want debug you will also need to set a level and component below | logging | 0 | 0 | 0 | | if you didn't have same result, you need removing the database zm and repeat step of create DB run next commands mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql mysql -uroot -p -e "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute,references on zm.* to 'zmuser'@localhost identified by 'zmpass';"

rbur004 commented 2 years ago

with mariadb you don't have a root password anymore, so it is mysql < /usr/share/zoneminder/db/zm_create.sql mysql -e "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute,references on zm.* to 'zmuser'@localhost identified by 'zmpass';"

abcdash commented 7 months ago

white screen problem after upgrade from 1.36.xx to 1.37.55 (with add-apt-repository ppa:iconnor/zoneminder-master) My solution: install (allow) PHP intl library (try to find in phpinfo() page first)

sudo apt install php-intl sudo phpenmod intl service apache2 restart

connortechnology commented 7 months ago

Closing this issue as there is no further action to take other than improving wiki/documentation content.