View Issue Details

IDProjectCategoryView StatusLast Update
1359RackTablesdefaultpublic2015-01-12 14:05
Reporternk Assigned Toandriyanov  
PrioritylowSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Product Version0.20.8 
Target Version0.20.9Fixed in Version0.20.9 
Summary1359: searching for comments does not work
DescriptionSearching IPs by comments doesn't work.
Steps To Reproduce1) Add a comment to a random IP
2) Search for the comment
3) No results will be found
Additional InformationPatch against 0.20.8 attached
TagsNo tags attached.

Activities

nk

nk

2014-11-25 11:20

reporter  

racktables-0.20.8-searchByComments.diff (2,747 bytes)   
diff --git a/racktables/inc/database.php b/racktables/inc/database.php
index a18b1bb..0c35d2d 100644
--- a/racktables/inc/database.php
+++ b/racktables/inc/database.php
@@ -2757,7 +2757,7 @@ function getIPv6PrefixSearchResult ($terms)
 
 function getIPv4AddressSearchResult ($terms)
 {
-	$query = "select ip, name from IPv4Address where ";
+	$query = "select ip, name, comment from IPv4Address where ";
 	$or = '';
 	$qparams = array();
 	foreach (explode (' ', $terms) as $term)
@@ -2766,6 +2766,12 @@ function getIPv4AddressSearchResult ($terms)
 		$or = ' or ';
 		$qparams[] = "%${term}%";
 	}
+	foreach (explode (' ', $terms) as $term)
+        {
+                $query .= $or . "comment like ?";
+                $or = ' or ';
+                $qparams[] = "%${term}%";
+        }
 	$result = usePreparedSelectBlade ($query, $qparams);
 	$ret = array();
 	while ($row = $result->fetch (PDO::FETCH_ASSOC))
@@ -2779,7 +2785,7 @@ function getIPv4AddressSearchResult ($terms)
 
 function getIPv6AddressSearchResult ($terms)
 {
-	$query = "select ip, name from IPv6Address where ";
+	$query = "select ip, name, comment from IPv6Address where ";
 	$or = '';
 	$qparams = array();
 	foreach (explode (' ', $terms) as $term)
@@ -2788,6 +2794,12 @@ function getIPv6AddressSearchResult ($terms)
 		$or = ' or ';
 		$qparams[] = "%${term}%";
 	}
+	foreach (explode (' ', $terms) as $term)
+        {       
+                $query .= $or . "comment like ?";
+                $or = ' or '; 
+                $qparams[] = "%${term}%";
+        } 
 	$result = usePreparedSelectBlade ($query, $qparams);
 	return reindexById ($result->fetchAll (PDO::FETCH_ASSOC), 'ip');
 }
diff --git a/racktables/inc/interface.php b/racktables/inc/interface.php
index 5dc63ba..19f5e27 100644
--- a/racktables/inc/interface.php
+++ b/racktables/inc/interface.php
@@ -3625,7 +3625,7 @@ function renderSearchResults ($terms, $summary)
 					startPortlet ('IPv6 addresses');
 				echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
 				// FIXME: address, parent network, routers (if extended view is enabled)
-				echo '<tr><th>Address</th><th>Description</th></tr>';
+				echo '<tr><th>Address</th><th>Description</th><th>Comment</th></tr>';
 				foreach ($what as $addr)
 				{
 					echo "<tr class=row_${order}><td class=tdleft>";
@@ -3640,7 +3640,7 @@ function renderSearchResults ($terms, $summary)
 							)) . "'>${fmt}</a></td>";
 					else
 						echo "<a href='index.php?page=ipaddress&tab=default&ip=${fmt}'>${fmt}</a></td>";
-					echo "<td class=tdleft>${addr['name']}</td></tr>";
+					echo "<td class=tdleft>${addr['name']}</td><td>${addr['comment']}</td></tr>";
 					$order = $nextorder[$order];
 				}
 				echo '</table>';
andriyanov

andriyanov

2015-01-12 14:05

reporter   ~0002639

Applied, thanks

Issue History

Date Modified Username Field Change
2014-11-25 11:20 nk New Issue
2014-11-25 11:20 nk File Added: racktables-0.20.8-searchByComments.diff
2015-01-12 14:05 andriyanov Note Added: 0002639
2015-01-12 14:05 andriyanov Status new => closed
2015-01-12 14:05 andriyanov Assigned To => andriyanov
2015-01-12 14:05 andriyanov Resolution open => fixed
2015-01-12 14:05 andriyanov Fixed in Version => 0.20.9
2015-01-12 14:05 andriyanov Target Version => 0.20.9