Skip to content

Text search displays all subnet folders for PHP 8.0+ #4476

@damienfinck

Description

@damienfinck

Describe the bug
The IPAM text search has a bug that systematically displays all subnetwork folders in the results if you do a text search.
If we do a search with an IP, we get the results that match our search.
If you do a text search, in the subnets section, all subnet folders are displayed, even though they don't match your search.
Subnet folders should only be displayed if the keyword is present in the folder name or description.
Furthermore, in my case, we have more than 100 folders. They are therefore necessarily all displayed systematically.

phpIPAM version
The bug doesn't depend on the IPAM version but on the PHP version used.

The problematic line of code is present in:

  • Latest git master development branch.
  • Latest production release 1.7.3.
  • Older obsolete release

In my case, I use a Docker image of the IPAM. The problem starts with version 1.6.1 and is still present in the latest production version (1.7.3).
The Docker image of IPAM version 1.6.0 uses PHP 7.4.33 => no bug when searching
The Docker image of IPAM version 1.6.1 uses PHP 8.2.20 => contains the search bug
The same applies to all versions above 1.6.1 (tested with v1.7.0, v1.7.1, v1.7.2, v1.7.3, 1.7x, latest and nightly found here https://hub.docker.com/r/phpipam/phpipam-www/tags).

Your Environment (please supply the following information):

  • phpIPAM version: 1.7.3
  • OS: Red Hat
  • PHP version: 8.3.14
  • Webserver: Apache
  • Database: 11.4.5

I use the official Docker image "phpipam/phpipam-www:v1.7.3" from https://hub.docker.com/r/phpipam/phpipam-www

Steps To Reproduce

  1. Go to the public instance of IPAM https://demo.phpipam.net
  2. Search for a word not present in the IPAM. For example "fdghfdhdgfhdfgdfdfddf", you will arrive on this page: https://demo.phpipam.net/tools/search/fdghfdhdgfhdfgdfdfddf
  3. In the “subnets” section, subnet folders are displayed even if they don't contain the word you're looking for.

Screenshots and error logs
Image

Additional Info
By going to the website https://onlinephp.io/, you can paste this piece of code:

<?php
# Initialization
$high = "";
$low = "";

# Debug
echo "high=".$high."\r\n";

# Code from https://github.com/phpipam/phpipam/blob/v1.7.3/functions/classes/class.Tools.php#L217
if($high==0 && $low==0)	{ $high = "1"; $low = "1"; }

# Debug
echo "high=".$high."\r\n";

Run it with PHP 7.4 and PHP 8.0 and you'll see that the “if” evaluation is now different. The condition was true n PHP 7.4 and is now false with PHP 8.0+.
This “if” is present here: https://github.com/phpipam/phpipam/blob/v1.7.3/functions/classes/class.Tools.php#L217

Here is the link with this snippet: https://onlinephp.io/c/ed50d

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions