Uploaded image for project: 'Observium'
  1. Observium
  2. OBS-3968

PHP error "Uncaught TypeError: in_array()" on SLA page

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • None
    • Enterprise Edition
    • Default
    • PHP8.0

    Description

      The SLA page (/slas) only displayed menu bar.

      In the PHP log, we can see this error :

      PHP Fatal error:  Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /opt/observium/21.12.11808/html/pages/slas.inc.php:146\nStack trace:\n#0 /opt/observium/21.12.11808/html/pages/slas.inc.php(146): in_array()\n#1 /opt/observium/21.12.11808/html/index.php(271): include('...')\n#2 {main}\n  thrown in /opt/observium/21.12.11808/html/pages/slas.inc.php on line 146'

       

      I thiking it's related to PHP 8.0.

      I solved the problem with this code modification line 146:

       

      -   if ($owner == $vars['owner'] || in_array($owner, $vars['owner']) )
      if ($owner == $vars['owner'] || (!safe_empty($vars['owner']) && in_array($owner, $vars['owner'])) )

       

       

      I don't know if this is the official method for Observium, but it works

       

      Attachments

        Activity

          People

            landy Mike Stupalov
            johann Johann Mallet
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: