r4910 APCPowerSwitch::getPorts () - change snmpwalk call to snmpwalkoid, fixes #504
[racktables] / wwwroot / inc / code.php
index 013e5125740139245f534323f9e98c6f95539a45..b162f6e0ba45169e66ff0b7cf9e35dc2e09cc512 100644 (file)
@@ -886,34 +886,52 @@ function findAutoTagWarnings ($expr)
                        {
                                case (preg_match ('/^\$id_/', $expr['load'])):
                                        $recid = preg_replace ('/^\$id_/', '', $expr['load']);
-                                       if (NULL !== spotEntity ('object', $recid))
+                                       try
+                                       {
+                                               spotEntity ('object', $recid);
                                                return array();
-                                       return array (array
-                                       (
-                                               'header' => refRCLineno ($expr['lineno']),
-                                               'class' => 'warning',
-                                               'text' => "An object with ID '${recid}' does not exist."
-                                       ));
+                                       }
+                                       catch (EntityNotFoundException $e)
+                                       {
+                                               return array (array
+                                               (
+                                                       'header' => refRCLineno ($expr['lineno']),
+                                                       'class' => 'warning',
+                                                       'text' => "An object with ID '${recid}' does not exist."
+                                               ));
+                                       }
                                case (preg_match ('/^\$ipv4netid_/', $expr['load'])):
                                        $recid = preg_replace ('/^\$ipv4netid_/', '', $expr['load']);
-                                       if (NULL != spotEntity ('ipv4net', $recid))
+                                       try
+                                       {
+                                               spotEntity ('ipv4net', $recid);
                                                return array();
-                                       return array (array
-                                       (
-                                               'header' => refRCLineno ($expr['lineno']),
-                                               'class' => 'warning',
-                                               'text' => "IPv4 network with ID '${recid}' does not exist."
-                                       ));
+                                       }
+                                       catch (EntityNotFoundException $e)
+                                       {
+                                               return array (array
+                                               (
+                                                       'header' => refRCLineno ($expr['lineno']),
+                                                       'class' => 'warning',
+                                                       'text' => "IPv4 network with ID '${recid}' does not exist."
+                                               ));
+                                       }
                                case (preg_match ('/^\$userid_/', $expr['load'])):
                                        $recid = preg_replace ('/^\$userid_/', '', $expr['load']);
-                                       if (NULL !== spotEntity ('user', $recid))
+                                       try
+                                       {
+                                               spotEntity ('user', $recid);
                                                return array();
-                                       return array (array
-                                       (
-                                               'header' => refRCLineno ($expr['lineno']),
-                                               'class' => 'warning',
-                                               'text' => "User account with ID '${recid}' does not exist."
-                                       ));
+                                       }
+                                       catch (EntityNotFoundException $e)
+                                       {
+                                               return array (array
+                                               (
+                                                       'header' => refRCLineno ($expr['lineno']),
+                                                       'class' => 'warning',
+                                                       'text' => "User account with ID '${recid}' does not exist."
+                                               ));
+                                       }
                                case (preg_match ('/^\$username_/', $expr['load'])):
                                        $recid = preg_replace ('/^\$username_/', '', $expr['load']);
                                        global $require_local_account;
@@ -939,15 +957,15 @@ function findAutoTagWarnings ($expr)
                                                'class' => 'warning',
                                                'text' => "Page number '${recid}' does not exist."
                                        ));
-                               case (preg_match ('/^\$(tab|op)_[\p{L}0-9]+$/u', $expr['load'])):
+                               case (preg_match ('/^\$(tab|op)_[\p{L}0-9_]+$/u', $expr['load'])):
                                case (preg_match ('/^\$any_(op|rack|object|ip4net|net|ipv4vs|vs|ipv4rsp|rsp|file)$/', $expr['load'])):
                                case (preg_match ('/^\$typeid_[[:digit:]]+$/', $expr['load'])): // FIXME: check value validity
                                case (preg_match ('/^\$cn_.+$/', $expr['load'])): // FIXME: check name validity and asset existence
                                case (preg_match ('/^\$lgcn_.+$/', $expr['load'])): // FIXME: check name validity
-                               case (preg_match ('/^\$(fromvlan|tovlan)_[[:digit:]]+$/', $expr['load'])):
+                               case (preg_match ('/^\$(vlan|fromvlan|tovlan)_[[:digit:]]+$/', $expr['load'])):
                                case (preg_match ('/^\$(unmounted|untagged|no_asset_tag|runs_8021Q)$/', $expr['load'])):
                                case (preg_match ('/^\$masklen_(eq|le|ge)_[[:digit:]][[:digit:]]?$/', $expr['load'])):
-                               case (preg_match ('/^\$attr_\d+_\d+$/', $expr['load'])):
+                               case (preg_match ('/^\$attr_\d+(_\d+)?$/', $expr['load'])):
                                        return array();
                                default:
                                        return array (array