ConSol-Monitoring / omd

OMD - Open Monitoring Distribution Labs Edition.
http://omd.consol.de
GNU General Public License v2.0
171 stars 35 forks source link

Creation of dynamic property Special_Controller::$templates is deprecated #210

Open infraweavers opened 6 days ago

infraweavers commented 6 days ago

Since upgrading our monitoring boxes to Debian 12 (Bookworm), this broke our pnp4nagios graphs.

This happened because due to the new PHP version installed and the dynamic properties being deprecated.

Example of error: "Creation of dynamic property Special_Controller::$templates is deprecated

file [line]: application/controllers/special.php [16]:"

The solution for this is to update the special.php on the OMD box.

The path for the file is: /opt/omd/versions/5.30-labs-edition/share/pnp4nagios/htdocs/application/controllers/special.php

The script needs to include all the properties so it should look like that:

<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Graph controller.
 *
 * @package    PNP4Nagios
 * @author     Joerg Linge
 * @license    GPL
 */

class Special_Controller extends System_Controller {

    // Explicitly declare the dynamic properties
    public $templates;
    public $url;
    public $template;
    public $tpl;
    public $data;
    public $view;

    public function __construct()
    {
        parent::__construct();
        $this->template        = $this->add_view('template');
        $this->template->graph = $this->add_view('graph');
        $this->templates       = $this->data->getSpecialTemplates();
        $this->data->GRAPH_TYPE = 'special';
        if ($this->tpl == '') {
            if ($this->templates)
                $this->tpl = $this->templates[0];
                url::redirect('special?tpl=' . $this->tpl, 302);
        }
    }

    public function index()
    {
        $this->url = "?tpl=" . $this->tpl;
        $this->template->zoom_header   = $this->add_view('zoom_header');
        $this->template->zoom_header->graph_width  = ($this->config->conf['zgraph_width'] + 140);
        $this->template->zoom_header->graph_height = ($this->config->conf['zgraph_height'] + 230);
        $this->template->graph->graph_content = $this->add_view('graph_content_special');
        $this->template->graph->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
        $this->template->graph->graph_content->timerange_select = $this->add_view('timerange_select');
        $this->template->graph->header        = $this->add_view('header');
        $this->template->graph->search_box    = $this->add_view('search_box');
        $this->template->graph->service_box   = $this->add_view('special_templates_box');
        #$this->template->graph->status_box    = $this->add_view('status_box');
        #$this->template->graph->basket_box    = $this->add_view('basket_box');
        $this->template->graph->widget_menu   = $this->add_view('widget_menu');
        $this->template->graph->graph_content->widget_graph  = $this->add_view('widget_graph');
        #print Kohana::debug($services);
        $this->data->buildDataStruct('__special', $this->tpl, $this->view);
        $this->template->graph->icon_box      = $this->add_view('icon_box');
        $this->template->graph->icon_box->position = "special";
        $this->template->graph->logo_box      = $this->add_view('logo_box');
        // Timerange Box Vars
        $this->template->graph->timerange_box = $this->add_view('timerange_box');
        $this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE;
        $this->template->graph->header->title        = $this->data->MACRO['TITLE'];
        //print Kohana::debug($this->data);
    }
}

If I put this in a pull request, is this likely to be accepted?

sni commented 6 days ago

Have you tried updating OMD? I have a feeling these issues are solved already?

infraweavers commented 5 days ago

We have not. We are still on 5.30 and didn't really think to check that. We shall update and if the issue persists we can update.

Thank you