Ad Widget

Collapse

trunk 7783: configuration -> actions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Palmertree
    Senior Member
    • Sep 2005
    • 746

    #1

    trunk 7783: configuration -> actions

    Get the following error in the httpd logs when going to configuration -> actions

    PHP Fatal error: Cannot use string offset as an array in /var/www/html/php/api/classes/class.caction.php on line 405
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    with rev 7798 i don't get such error, but i get a different one
    Invalid argument supplied for foreach()[/usr/local/apache2/htdocs/zabbix-1.6.5/actionconf.php:523]
    Zabbix 3.0 Network Monitoring book

    Comment

    • Palmertree
      Senior Member
      • Sep 2005
      • 746

      #3
      Still getting the error "PHP Fatal error: Cannot use string offset as an array in /var/www/html/php/api/classes/class.caction.php on line 405" on Trunk 7808. Only shows up with certain operations set in the actions.

      Here is the fix incase anyone else is getting this error too:

      Tested on Trunk 7808:

      Code:
      diff -ruN zabbix-original/frontends/php/api/classes/class.caction.php zabbix/frontends/php/api/classes/class.caction.php
      --- zabbix-original/frontends/php/api/classes/class.caction.php 2009-08-18 22:35:49.000000000 -0400
      +++ zabbix/frontends/php/api/classes/class.caction.php  2009-08-18 22:45:20.000000000 -0400
      @@ -401,7 +401,9 @@
                              $sql = 'SELECT op.* FROM opconditions op WHERE '.DBcondition('op.operationid', $operationids);
                              $res = DBselect($sql);
                              while($opcondition = DBfetch($res)){
      +                               $operations[$opcondition['operationid']]['opconditions'][$opcondition['opconditionid']] = array();
                                      $operations[$opcondition['operationid']]['opconditions'][$opcondition['opconditionid']] = $opcondition;
      +                               $operationids[$opcondition['operationid']] = array();
                                      $operationids[$opcondition['operationid']]['opconditionids'][$opcondition['opconditionid']] = $opcondition['opconditionid'];
                              }
      Some more info:
      PHP5 Error message that is caused by attempting to assign a value to an array element of a variable that is declared as a string.

      Example that generates error:

      $foo=’bar’;
      $foo[0]=’bar’;
      Get error message Fatal error: Cannot use string offset as an array in …
      Explanation
      $foo was declared as a string in $foo=’bar’.
      $foo[0] is trying to append an element onto a string variable.

      Example that does not generate error:

      $foo[0]=’bar’;
      $foo=’bar’;
      Does NOT generate error.
      Explanation
      $foo[0]=’bar’ instantiates variable $foo as array since it has not been instantiated. Then assigns ‘bar’ to element $foo[0].
      $foo=’bar’ implicitly re-declares $foo as a string and assigns ‘bar’ to it.

      Example that does not generate error:

      $foo=’bar’;
      $foo=array();
      $foo[0]=’bar’;
      Explanation
      $foo=’bar’ implicitly declares $foo as a string variable then assigns ‘bar’ as the value.
      $foo=array() explicitly re-declares $foo as an array.
      $foo[0]=’bar’ can now be executed as $foo is declared as an array.
      Last edited by Palmertree; 19-08-2009, 05:26.

      Comment

      • richlv
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2005
        • 3112

        #4
        btw, i'm trying to document apparrent known trunk bugs on a single page at http://www.zabbix.com/wiki/doku.php?id=contrib:trunk

        otherwise i'ts too easy to get lost in the forum
        Zabbix 3.0 Network Monitoring book

        Comment

        Working...