diff --git a/web/includes/actions/monitor.php b/web/includes/actions/monitor.php index 0a04fdbeb..762a98729 100644 --- a/web/includes/actions/monitor.php +++ b/web/includes/actions/monitor.php @@ -19,7 +19,7 @@ // // Monitor edit actions, monitor id derived, require edit permissions for that monitor -if ( ! canEdit('Monitors') ) { +if ( !canEdit('Monitors') ) { ZM\Warning('Monitor actions require Monitors Permissions'); return; } @@ -34,8 +34,7 @@ if ( $action == 'save' ) { } if ( ZM_OPT_X10 ) { $x10Monitor = dbFetchOne('SELECT * FROM TriggersX10 WHERE MonitorId=?', NULL, array($mid)); - if ( !$x10Monitor ) - $x10Monitor = array(); + if ( !$x10Monitor ) $x10Monitor = array(); } } else { if ( $user['MonitorIds'] ) { @@ -88,6 +87,7 @@ if ( $action == 'save' ) { $restart = false; if ( count($changes) ) { + // monitor->Id() has a value when the db record exists if ( $monitor->Id() ) { # If we change anything that changes the shared mem size, zma can complain. So let's stop first. @@ -212,9 +212,7 @@ if ( $action == 'save' ) { # FIXME This is actually a race condition. Should lock the table. $maxSeq = dbFetchOne('SELECT MAX(Sequence) AS MaxSequence FROM Monitors', 'MaxSequence'); $changes['Sequence'] = $maxSeq+1; - if ( $mid and !$monitor->Id() ) { - $changes['Id'] = $mid; - } + if ( $mid ) $changes['Id'] = $mid; # mid specified in request, doesn't exist in db, will re-use slot if ( $monitor->insert($changes) ) { $mid = $monitor->Id();