Can't edit zones, no points Javascript?

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
milonic
Posts: 11
Joined: Mon Jul 19, 2021 7:49 pm

Can't edit zones, no points Javascript?

Post by milonic »

Hi All,

I'm having trouble editing zones in 1.36.24

The page loads up and when I try to edit, it shows the cam and zone but the points are not there.

Here's a copy of browser console

Code: Select all

Uncaught SyntaxError: "" string literal contains an unescaped line break zm:820:23
Uncaught ReferenceError: $j is not defined
    <anonymous> /zm/cache/skins_classic_views_js_zone-base-1659792210.js:1
skins_classic_views_js_zone-base-1659792210.js:1:16
Uncaught ReferenceError: currentView is not defined
    <anonymous> /zm/cache/skins_classic_js_skin-base-1659792210.js:260
skins_classic_js_skin-base-1659792210.js:260:6
Uncaught ReferenceError: $j is not defined
    <anonymous> /zm/cache/js_logger-base-1659792210.js:19
js_logger-base-1659792210.js:19:1
Uncaught ReferenceError: $j is not defined
Hoping someone can help
milonic
Posts: 11
Joined: Mon Jul 19, 2021 7:49 pm

Re: Can't edit zones, no points Javascript?

Post by milonic »

I found the problem.

It's yet more PHP 8 depreciated fun.

On line 107 in /usr/share/zoneminder/www/skins/classic/views/js/zone.js.php there's this:

Code: Select all

var streamSrc = "<?php echo preg_replace( '/&amp;/', '&', $streamSrc ) ?>";
but PHP 8.1 now returns this error:

Code: Select all

Deprecated:  preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in <b>/usr/share/zoneminder/www/skins/classic/views/js/zone.js.php</b> on line <b>107<
I have temporarily fixed it with this:

Code: Select all

var streamSrc = "<?php echo preg_replace( '/&amp;/', '&', $streamSrc ?? '' ) ?>";
But i'm not sure it's the best approach, as null coalescing operator was introduced in PHP 7.0 depends how far back Zoneminder supports PHP.

Anyway, it's a start to help pin-point the problem.
milonic
Posts: 11
Joined: Mon Jul 19, 2021 7:49 pm

Re: Can't edit zones, no points Javascript?

Post by milonic »

Here's a better solution:

Code: Select all

var streamSrc = "<?php echo preg_replace( '/&amp;/', '&', strval($streamSrc)) ?>";
but then, PHP will probably remove passing null to strval in the future, so, how about this instead.

Code: Select all

var streamSrc = "<?php echo preg_replace( '/&amp;/', '&', $streamSrc.'') ?>";
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Can't edit zones, no points Javascript?

Post by Magic919 »

Isaac loves all that deprecated stuff.
-
milonic
Posts: 11
Joined: Mon Jul 19, 2021 7:49 pm

Re: Can't edit zones, no points Javascript?

Post by milonic »

Magic919 wrote: Sun Aug 21, 2022 10:50 am Isaac loves all that deprecated stuff.
I bet he does, lol
smithjw1
Posts: 16
Joined: Sat Nov 20, 2021 2:53 pm

Re: Can't edit zones, no points Javascript?

Post by smithjw1 »

What OS do you have and what is the maint level of PHP 8.1? I am running Ubuntu 22.02.1 and PHP 8.1.2 which was last updated 7/21/2022 and I do not have this problem with the points.
milonic
Posts: 11
Joined: Mon Jul 19, 2021 7:49 pm

Re: Can't edit zones, no points Javascript?

Post by milonic »

smithjw1 wrote: Tue Aug 23, 2022 1:38 pm What OS do you have and what is the maint level of PHP 8.1? I am running Ubuntu 22.02.1 and PHP 8.1.2 which was last updated 7/21/2022 and I do not have this problem with the points.
It's probably because I have errors switched on and set quite high in PHP that I am seeing this and you are not.
webdriver
Posts: 13
Joined: Mon Aug 15, 2022 5:28 am

Re: Can't edit zones, no points Javascript?

Post by webdriver »

Not sure if it's related -- when I was on ZM 1.34 (old version), I had a time can't edit zone with Chrome but good go with FF browser.
Then someday things changed FF can't edit zone as well so I use IE (from another VM with earlier version Windows)
Definitely browser/JS engine compatibility issues for me
Post Reply