Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Host search not saved when activate/desactivate a host #5711

Closed
lolokai opened this issue Sep 27, 2017 · 5 comments
Closed

Host search not saved when activate/desactivate a host #5711

lolokai opened this issue Sep 27, 2017 · 5 comments

Comments

@lolokai
Copy link
Contributor

lolokai commented Sep 27, 2017

1.<!--
If you are reporting a new issue, make sure that we do not have any duplicates already open. You
can ensure this by searching the issue list for this repository. If there is a duplicate, please
close your issue and add a comment to the existing issue instead.

If you think that your problem is a bug, please add a description organized like the BUG REPORT
INFORMATION shown below. If you can't provide all this information, it's possible that we will not
be able to debug and fix your problems, and so we will be obliged to close the ticket. Nevertheless,
You will be able to provide them later in order to reactivate it.

When we need more information, we will reply in order to ask some element in order. If you do not answer
in the next 30 days, the ticket will be automaticaly closed.

Thank you to describe your issue in English.
-->


BUG REPORT INFORMATION

Centreon Web version: 2.8.13

Centreon Engine version: 1.8.0

Centreon Broker version: 3.0.9

OS: CentOS 6 - Install from RPM

Additional environment details (AWS, VirtualBox, physical, etc.):

Steps to reproduce the issue:

  1. Go to Configuration - Hosts
  2. Make a search
  3. Activate a desactivate host

Describe the results you received:
The search is lost

Describe the results you expected:
The search should be keep

Additional information you think important (e.g. issue happens only occasionally):

@lolokai
Copy link
Contributor Author

lolokai commented Sep 27, 2017

Same thing when you modify the host

@kadrika
Copy link

kadrika commented Oct 2, 2017

I have the same issue.

@mavynet
Copy link

mavynet commented Oct 4, 2017

This is because the search form makes a POST request with 'searchH' as hostname key, but the disable/enable button makes a GET request with 'search' as the key.

As a quick fix I replaced '$_POST["searchH"]' with '$_REQUEST["searchH"]' on lines 65, 66, 67 in /usr/share/centreon/www/include/configuration/configObject/host/listHost.php and replaced 'search' with 'searchH' on lines 272 and 274 in the same file (theese are the links of the disable/enable button)

Hope this helps until the bug is fixed

@lpinsivy
Copy link
Contributor

lpinsivy commented Oct 4, 2017

I prefer to use explicitly _GET and _POST instead of _REQUEST

# diff -Nru listHost.php.origin listHost.php
--- listHost.php.origin	2017-10-04 13:26:32.296048331 +0200
+++ listHost.php	2017-10-04 13:34:38.109019375 +0200
@@ -64,7 +64,9 @@

 if (isset($_POST["searchH"])) {
     $search = $_POST["searchH"];
-    $_POST["search"] = $_POST["searchH"];
+    $centreon->historySearch[$url] = $search;
+} elseif (isset($_GET["searchH"])) {
+    $search = $_GET["searchH"];
     $centreon->historySearch[$url] = $search;
 } elseif (isset($centreon->historySearch[$url])) {
     $search = $centreon->historySearch[$url];
@@ -269,9 +271,9 @@
         $selectedElements = $form->addElement('checkbox', "select[".$host['host_id']."]");

         if ($host["host_activate"]) {
-            $moptions = "<a href='main.php?p=".$p."&host_id=".$host['host_id']."&o=u&limit=".$limit."&num=".$num."&search=".$search."'><img src='img/icons/disabled.png' class='ico-14 margin_right' border='0' alt='"._("Disabled")."'></a>";
+            $moptions = "<a href='main.php?p=".$p."&host_id=".$host['host_id']."&o=u&limit=".$limit."&num=".$num."&searchH=".$search."'><img src='img/icons/disabled.png' class='ico-14 margin_right' border='0' alt='"._("Disabled")."'></a>";
         } else {
-            $moptions = "<a href='main.php?p=".$p."&host_id=".$host['host_id']."&o=s&limit=".$limit."&num=".$num."&search=".$search."'><img src='img/icons/enabled.png' class='ico-14 margin_right' border='0' alt='"._("Enabled")."'></a>";
+            $moptions = "<a href='main.php?p=".$p."&host_id=".$host['host_id']."&o=s&limit=".$limit."&num=".$num."&searchH=".$search."'><img src='img/icons/enabled.png' class='ico-14 margin_right' border='0' alt='"._("Enabled")."'></a>";
         }

         $moptions .= "<input onKeypress=\"if(event.keyCode > 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$host['host_id']."]'></input>";

@adr-mo
Copy link
Contributor

adr-mo commented Nov 27, 2017

Issue reproduced on a 2.8.16 version of Centreon.

Applying the patch has fixed the issue.

Looks good to me.

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

No branches or pull requests

5 participants