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

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

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

          [OBS-3968] PHP error "Uncaught TypeError: in_array()" on SLA page
          bot Observium Bot made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]
          landy Mike Stupalov made changes -
          Labels Original: SLA web New: SLA php8 web
          landy Mike Stupalov made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]

          Fixed in r11819.

          landy Mike Stupalov added a comment - Fixed in r11819.
          landy Mike Stupalov made changes -
          Status Original: In Review [ 10101 ] New: In Progress [ 3 ]
          landy Mike Stupalov made changes -
          Status Original: Pending Response [ 10000 ] New: In Review [ 10101 ]

          Ugh. I miss click . It's Profesionnal Version.

          Not possible edit the original message. Sorry!

          johann Johann Mallet added a comment - Ugh. I miss click . It's Profesionnal Version. Not possible edit the original message. Sorry!
          bot Observium Bot made changes -
          Component/s New: Default [ 10900 ]
          bot Observium Bot made changes -
          Assignee Original: Adam Armstrong [ adama ] New: Mike Stupalov [ landy ]
          bot Observium Bot made changes -
          Status Original: Open [ 1 ] New: Pending Response [ 10000 ]
          johann Johann Mallet created issue -

          People

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

            Dates

              Created:
              Updated:
              Resolved: