[ZBX-4563] Problems with user defined macros Created: 2012 Jan 19  Updated: 2017 May 30  Resolved: 2012 Feb 27

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A), Frontend (F)
Affects Version/s: 1.9.8 (beta)
Fix Version/s: 2.0.0rc1

Type: Incident report Priority: Critical
Reporter: Alexander Vladishev Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: usermacros
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

trunk, r24888


Attachments: JPEG File admin.jpg     JPEG File distance-between-macros.jpg     JPEG File super-admin.jpg    
Issue Links:
Duplicate
is duplicated by ZBX-4669 API method "usermacro.updateglobal" d... Closed

 Description   

Some problems found with user macros:

1. host and template level macros:

  • some macros can disappear at their saving; how to repeat a problem:
    a. add two macros {$A} and {$B}
    b. remove macro {$A}
    c. add macro {$C} and save host or template
    d. only {$C} macro will be saved

2. template level macros:

  • the distance between macros isn't enough (see a screenshot)

3. the source code for template/host and global level macros is very different; it should be unified

4. the validation order of macros isn't logical

5. in API there aren't some checks

  • a check for duplicated macros

6. error messages violates coding style; for example:
frontends/php/api/classes/class.cusermacro.php:735, 738



 Comments   
Comment by Pavels Jelisejevs (Inactive) [ 2012 Feb 07 ]

We've discussed it with Vedmak and Eduard, and decided, that from now on, each public API method will have it's own validator, instead of a single monstrous checkInput-like method. Each validator will consist of multiple, mostly independent checks. That way the validation process will be clearer and more flexible.

RESOLVED.

<Eduard> CLOSED

Comment by richlv [ 2012 Feb 08 ]

(7) api documentation doesn't seem to be updated (both individual method pages and http://www.zabbix.com/documentation/2.0/manual/appendix/api/changes_1.8_-_2.0 )

<pavels> Yeah, I'll update the docs as soon as the fix is reviewed and tested.

<pavels> Updated the changes section http://www.zabbix.com/documentation/2.0/manual/appendix/api/changes_1.8_-_2.0 and the API docs http://www.zabbix.com/documentation/2.0/manual/appendix/api/usermacro?&#methods

<Sasha> CLOSED

Comment by Eduards Samersovs (Inactive) [ 2012 Feb 14 ]

(8) After saving host with user macros, macros will doubles (if user is not Super Admin).

<pavels> RESOLVED.
<Eduard> CLOSED

Comment by Eduards Samersovs (Inactive) [ 2012 Feb 20 ]

(9) Duplicate "form_refresh" variable in administration->general->user macros page

<pavels> RESOLVED.
<Eduard> CLOSED

Comment by Eduards Samersovs (Inactive) [ 2012 Feb 20 ]

(10) Typo in message: Macro "%1$s is not unique."

<pavels> RESOLVED.
<Eduard> CLOSED

Comment by Pavels Jelisejevs (Inactive) [ 2012 Feb 20 ]

(11) Permission checks should be made prior to everything else.

<pavels> RESOLVED.
<Eduard> CLOSED

Comment by Eduards Samersovs (Inactive) [ 2012 Feb 20 ]

(12) Login as common Admin user. Edit some host where exist {$A} and {$B}. Create {$C} and delete {$B} - error message is shown..
array_merge(): Argument #1 is not an array [api/classes/class.cusermacro.php:622]
Argument 1 passed to CUserMacro::checkHostPermissions() must be an array, null given, called in /home/zabbix/www/testing-ZBX-4563/frontends/php/api/classes/class.cusermacro.php on line 623 and defined [api/classes/class.cusermacro.php:865]
Invalid argument supplied for foreach() [api/classes/class.cusermacro.php:881]

<pavels> RESOLVED.
<Eduard> CLOSED

Comment by Eduards Samersovs (Inactive) [ 2012 Feb 22 ]

(13) Global macros ordering is jumping after saving.

<pavels> RESOLVED.
<Eduard> CLOSED

Comment by Alexander Vladishev [ 2012 Feb 22 ]

(14) in fields, created dynamically an 'id' property are missing.

value:
<input class="input text" type="text" id="macros_2_value" name="macros[2][value]" size="40" maxlength="255" placeholder="value">
<input class="input text" type="text" name="macros[3][value]" size="40" maxlength="255" placeholder="value">

button:
<input class="input button shadow ui-corner-all link_menu macroRemove" type="button" id="macros_del" name="macros_del" value="Remove" onclick="">
<input class="input link_menu macroRemove" type="button" value="Remove" data-is-new="1">

<pavels> RESOLVED.
<Sasha> CLOSED

Comment by Alexander Vladishev [ 2012 Feb 22 ]

(15) Very strange SQL requests while saving macros
The rights are checked some times.

5 macros updated
2 macros added

https://support.zabbix.com/secure/attachment/18100/super-admin.jpg
https://support.zabbix.com/secure/attachment/18101/admin.jpg

<Sasha> CLOSED

Comment by Alexander Vladishev [ 2012 Feb 24 ]

Great work! Successfully tested.

Don't forget to update API documentation.

Comment by Alexander Vladishev [ 2012 Feb 27 ]

Related issue: ZBX-4621

Comment by Pavels Jelisejevs (Inactive) [ 2012 Feb 27 ]

Merged to trunk r25614.

Comment by Alexander Vladishev [ 2012 Feb 27 ]

(16) Please change validateCreate() function to protected.

<pavels> CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2012 Feb 27 ]

CLOSED.

Generated at Fri Apr 19 18:03:25 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.