[ZBX-10373] incorrect screenitem x, y update Created: 2016 Feb 11  Updated: 2024 Apr 10  Resolved: 2018 Jun 29

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 3.0.0rc1
Fix Version/s: 3.0.9rc1, 3.2.5rc1, 3.4.0alpha1

Type: Incident report Priority: Major
Reporter: vitalijs.cemeris (Inactive) Assignee: Gregory Chalenko
Resolution: Fixed Votes: 0
Labels: screenitem, update
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File ZBX-10373.png     File zbx-10373.csv    
Team: Team D
Team: Team D
Sprint: Sprint 3, Sprint 4, Sprint 5, Sprint 36, Sprint 37
Story Points: 0.5

 Description   

Reproduce:
Create screen with two screenitems. First with position x=2, y=1 and second with position x=3, y=1.
Now update second screnitem position to x=2, y=1

Note:
Update is successful. As a result two screenitems are in same position in one screen.



 Comments   
Comment by richlv [ 2016 Feb 11 ]

can this be considered yet another case of ZBX-3783 ?

Comment by Gunars Pujats (Inactive) [ 2016 Feb 18 ]

RESOLVED in development branch svn://svn.zabbix.com/branches/dev/ZBX-10373

Comment by Alexander Vladishev [ 2016 Mar 08 ]

(4) Why SQL requests have been replaced with API? It must be tested for performance issues.

@@ -152,14 +152,14 @@
                $screenIds = zbx_objectValues($screenItems, 'screenid');
 
                // fetch the items we're updating
-               $dbScreenItems = API::getApi()->select('screens_items', array(
+               $dbScreenItems = $this->get(array(
                        'screenids' => $screenIds,
                        'output' => API_OUTPUT_EXTEND,
                        'preservekeys' => true
                ));
 
-               $screens = API::getApi()->select('screens', array(
-                       'output' => array('screenid', 'hsize', 'vsize'),
+               $screens = API::Screen()->get(array(
+                       'output' => array('screenid', 'hsize', 'vsize', 'name'),
                        'screenids' => $screenIds,
                        'preservekeys' => true
                ));
@@ -230,8 +221,8 @@
                }
                $screenItemIds = zbx_objectValues($screenItems, 'screenitemid');
 
-               $screens = API::getApi()->select('screens', array(
-                       'output' => array('screenid', 'hsize', 'vsize'),
+               $screens = API::Screen()->get(array(
+                       'output' => array('screenid', 'hsize', 'vsize', 'name'),
                        'screenitemids' => $screenItemIds,
                        'preservekeys' => true
                ));
@@ -247,14 +238,16 @@
 
                // old validation
                // fetch the items we're updating
-               $dbScreenItems = API::getApi()->select('screens_items', array(
-                       'screenitemids' => $screenItemIds,
+               $dbScreenItems = $this->get(array(
                        'output' => API_OUTPUT_EXTEND,
+                       'screenids' => zbx_objectValues($screens, 'screenid'),
                        'preservekeys' => true
                ));
 

oleg.egorov REVIEWED by gcalenko

CLOSED

Comment by Gregory Chalenko [ 2017 Mar 20 ]

Changes:

-               $dbScreenItems = API::getApi()->select('screens_items', array(
+               $dbScreenItems = $this->get(array(

Not critical, class CScreenItem contains method get which uses requests SQL, not API.

Comment by Gregory Chalenko [ 2017 Mar 20 ]

Change:

-               $screens = API::getApi()->select('screens', array(
-                       'output' => array('screenid', 'hsize', 'vsize'),
+               $screens = API::Screen()->get(array(
+                       'output' => array('screenid', 'hsize', 'vsize', 'name'),

Have impact on performance ~0.02sec for 300 request. Attached .csv file with performance test results, where 25 first rows contains measurement when API::Screen were called before SQL methods and next 25 rows contains measurements when API::Screen were called after SQL methods

Comment by Gregory Chalenko [ 2017 Apr 04 ]

Fixed in: svn://svn.zabbix.com/branches/dev/ZBX-10373 r67057

Comment by Alexander Vladishev [ 2017 Apr 04 ]

(1) No translation strings changes

gcalenko CLOSED

Comment by Alexander Vladishev [ 2017 Apr 05 ]

(2) [F] frontends/php/include/classes/api/services/CScreenItem.php:160: It will be more correct. The order of keys won't change when using + instead of array_merge()

$screenItem += $defaults;

gcalenko RESOLVED r67062

sasha CLOSED

Comment by Alexander Vladishev [ 2017 Apr 05 ]

(3) [F] Formatting issues

  1. frontends/php/include/classes/api/services/CScreenItem.php:297: the line is too long
  2. checkDuplicateResourceInCell(): this function is incorrectly formatted

gcalenko RESOLVED r67072

sasha CLOSED with minor changes in r67099

Comment by Alexander Vladishev [ 2017 Apr 05 ]

(4) [F] frontends/php/include/classes/api/services/CScreenItem.php:909: this will not work with different type of arrays (associative and indexed arrays)

$screenItems = zbx_array_merge($dbScreenItems, $screenItems);

gcalenko RESOLVED r67072

sasha CLOSED

Comment by Alexander Vladishev [ 2017 Apr 06 ]

Successfully tested! Have a look at my changes in r67099 before a merge.

Comment by Gregory Chalenko [ 2017 Apr 10 ]

Fixed in:

  • 3.0 r67167
  • 3.2 r67168
  • 3.4.0alpha1 (trunk) r67169
Comment by Ivo Kurzemnieks [ 2018 Feb 15 ]

(5) [D]

  1. API documentation is missing information about this fix.
  2. The screen.create example in documentation is not working. It complains about "row span in cell X - 0 Y - 0 is incorrect." In code, I see the defaults are colspan and rowspan are actually 1. Take a look at this too, please.

gcalenko Updated documentation for screen.create example.

RESOLVED

iivs Great, but the only thing 4.0 example was not changed.
Fixed screen.create for 4.0 as well.

CLOSED

Generated at Sat Apr 20 17:56:32 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.