Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 203 forks source link

Self Service API not working with PHP 8.2.7 #2827

Closed seoni-at closed 10 months ago

seoni-at commented 1 year ago

Expected Behavior

Self service should work

Current Behavior

Icinga For Windows fails using the Self Service API.

Possible Solution

This code Block produces deprecated output and prevents parsing of the json. https://github.com/Icinga/icingaweb2-module-director/blob/aa31b37fd184228d3397c512ae8fc175f2d82d39/application/controllers/SelfServiceController.php#L403-L411

<b>Deprecated</b>:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in <b>/usr/share/icingaweb2/modules/director/application/controllers/SelfServiceController.php</b> on line <b>407</b><br />\n

I fixed it in my installation with checking if the $value is null but my php knowledge is not the best so i do not know if there is a better way.

    protected function addStringSettingsToParams(Settings $settings, array $keys, array &$params)
    {
        foreach ($keys as $key) {
            $value = $settings->get("self-service/$key");
            if ($value != null) {
                if (strlen($value)) {
                    $params[$key] = $value;
                }
            }
        }
    }

Steps to Reproduce (for bugs)

Install icinga director on Debian 12 bookworm with php 8.2.7 and try to add a host using the self service api. Using wireshark the response sent to icinga for windows is the following

<br />
<b>Deprecated</b>:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in <b>/usr/share/icingaweb2/modules/director/application/controllers/SelfServiceController.php</b> on line <b>407</b><br />
<br />
<b>Deprecated</b>:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in <b>/usr/share/icingaweb2/modules/director/application/controllers/SelfServiceController.php</b> on line <b>407</b><br />
{
    "fetch_agent_name": false,
    "fetch_agent_fqdn": true,
    "transform_hostname": "1",
    "flush_api_directory": true,
    "resolve_parent_host": "0",
    "install_framework_service": "0",
    "install_framework_plugins": "0",
    "director_host_object": "{\"address\":\"&ipaddress&\",\"display_name\":\"&hostname.lowerCase&\"}",
    "download_url": "https://packages.icinga.com/windows/",
    "agent_version": "2.14.0",
    "allow_updates": true,
    "agent_listen_port": 5665,
    "install_nsclient": true
} 

Your Environment