Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-15876

Fix web scenarios item creation through API with php7.0

    XMLWordPrintable

Details

    • Patch request
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 4.0.5
    • None
    • API (A)
    • None
    • Team A

    Description

      This bug is a known issue: https://www.zabbix.com/documentation/4.0/manual/installation/known_issues#compatibility_issue_with_php_70

      It could be useful to fix this bug for those who cannot update to php7.1 or later.

       

      Steps to reproduce:

      1. Try to push a template with a web scenario and a trigger trough the API

      Versions:

      • zabbix-frontend-php:  1:4.0.5-1+stretch 
      • php7.0-fpm: 7.0.33-0+deb9u3

       

      Result:

       

      Error -32602: Invalid params., Incorrect item key "web.test.fail[<WEB SCENARIO NAME>]" provided for trigger expression on "<TEMPLATE NAME>". while sending...)
      

      Expected: Working API call

       

      This issue seems to come from the web scenario items that are not properly generated because of a bug in php7.0.

      Some unnecessary quotes are added in the item "key_" (if you push a template without trigger, the API call is ok but... you cannot assign the template to a host later).

      zabbix=# select itemid,hostid,name,key_ from items ORDER BY itemid DESC limit 20;
       itemid | hostid |                      name                      |                                key_                                
      --------+--------+------------------------------------------------+--------------------------------------------------------------------
      ...
      29094 |  10287 | Last error message of scenario "$1".           | web.test.error['my_test_1']
        29093 |  10287 | Failed step of scenario "$1".                  | web.test.fail['my_test_1']
        29092 |  10287 | Download speed for scenario "$1".              | web.test.in['my_test_1',,bps]
      

       

       

      The issue seems to be located in include/classes/api/managers/CHttpTestManager.php when the function createHttpTestItems is called.

      The array httpTest in parameters looks like this :

       

      (
          [0] => Array
              (
                  [status] => 0
                  [verify_host] => 0
                  [name] => my_test_1
                  [variables] => Array
      .....
      

      But when it gets the "name" value, it ended up with additional quotes

       

      protected function createHttpTestItems(array $httpTest) {
          error_log('HTTP TEST NAME : '.$httpTest['name']);
      

      Log output:

       

       

      [26-Mar-2019 12:09:04 Europe/Berlin] HTTP TEST NAME : 'my_test_1'

       

      A quick workaround in createHttpTestItems function seems to do the job:

       

       

      protected function createHttpTestItems(array $httpTest) {
      
          if( strnatcmp(phpversion(),'7.0') >= 0 )
          {
              $httpTest['name'] = trim($httpTest['name'],'\'');
          } 
      

       

       

      Same issue as:

       

      Attachments

        Issue Links

          Activity

            People

              zabbix.dev Zabbix Development Team
              eriviere Emmanuel Riviere
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: