Page 1 of 1

Can't edit zones, no points Javascript?

Posted: Sat Aug 20, 2022 9:35 am
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

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

Posted: Sun Aug 21, 2022 10:12 am
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.

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

Posted: Sun Aug 21, 2022 10:46 am
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.'') ?>";

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

Posted: Sun Aug 21, 2022 10:50 am
by Magic919
Isaac loves all that deprecated stuff.

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

Posted: Tue Aug 23, 2022 11:19 am
by milonic
Magic919 wrote: Sun Aug 21, 2022 10:50 am Isaac loves all that deprecated stuff.
I bet he does, lol

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

Posted: Tue Aug 23, 2022 1:38 pm
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.

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

Posted: Thu Aug 25, 2022 7:56 am
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.

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

Posted: Fri Aug 26, 2022 6:46 am
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