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

Self Service API not working with PHP 8.2.7 #2827

Closed
seoni-at opened this issue Oct 30, 2023 · 0 comments · Fixed by #2858
Closed

Self Service API not working with PHP 8.2.7 #2827

seoni-at opened this issue Oct 30, 2023 · 0 comments · Fixed by #2858
Labels
Milestone

Comments

@seoni-at
Copy link

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.

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

<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

  • Director version (System - About): 1.11.0

  • Icinga Web 2 version and modules (System - About): 2.12.0
    Loaded Libraries
    icinga/icinga-php-library 0.13.0
    icinga/icinga-php-thirdparty 0.12.0
    Loaded Modules
    director 1.11.0
    doc 2.12.0
    icingadb 1.1.0
    incubator 0.20.0
    translation 2.12.0

  • Icinga 2 version (icinga2 --version): r2.14.0-1

  • Operating System and version:
    System information:
    Platform: Debian GNU/Linux
    Platform version: 12 (bookworm)
    Kernel: Linux
    Kernel version: 6.1.0-13-amd64
    Architecture: x86_64

  • Webserver, PHP versions: PHP 8.2.7 (cli) (built: Jun 9 2023 19:37:27) (NTS)

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

Successfully merging a pull request may close this issue.

2 participants