-
Problem report
-
Resolution: Fixed
-
Critical
-
5.0.1
-
Sprint 66 (Jul 2020)
-
0.5
Slow funtion errorMessage in CUserMacroParser.php when using trigger.get API.
trigger.get JSON:
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"group": "XXXXXXXXXXXXXXXXXX",
"filter": {
"state": 0,
"status": 0,
"description": ["XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXX"]
},
"monitored": true,
"expandDescription": true,
"skipDependent": true,
"selectHosts": ["name", "host_id"],
"output": [
"description",
"priority",
"value"
]
},
"auth": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"id": 1
}
Changing function as below reduced 500ms on API call.
private function errorMessage($source, $pos) { if (!isset($source[$pos])) { return ($pos == 0) ? _('macro is empty') : _('unexpected end of macro'); } /*for ($p = $pos, $chunk = '', $maxChunkSize = 50; isset($source[$p]); $p++) { if (0x80 != (0xc0 & ord($source[$p])) && $maxChunkSize-- == 0) { break; } $chunk .= $source[$p]; } if (isset($source[$p])) { $chunk .= ' ...'; }*/ return 'incorrect syntax...'; }