Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
infraweavers opened this issue Nov 20, 2024 · 2 comments

Comments

@infraweavers
Copy link
Contributor

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
Copy link
Contributor

sni commented Nov 20, 2024

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

@infraweavers
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants