Commit 19508f02925591bb558f8174a9f1d1e8578803eb

Authored by megan_w
1 parent 52e820fc

KTS-3912 - Implemented fixes to check the arrays before using them.

"Problems with the search functionality in web services."

Committed by: Megan Watson
Reviewed by: Donald Jackson




git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/branches/RB_3.5.4a@9623 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/search/expr.inc.php
@@ -2317,9 +2317,12 @@ class OpExpr extends Expr @@ -2317,9 +2317,12 @@ class OpExpr extends Expr
2317 } 2317 }
2318 2318
2319 $permResults = array(); 2319 $permResults = array();
2320 - foreach($result[$resultContext] as $idx=>$item) 2320 + if(isset($result[$resultContext]))
2321 { 2321 {
2322 - $permResults[$resultContext][$idx] = $item; 2322 + foreach($result[$resultContext] as $idx=>$item)
  2323 + {
  2324 + $permResults[$resultContext][$idx] = $item;
  2325 + }
2323 } 2326 }
2324 2327
2325 return $permResults; 2328 return $permResults;
search2/search/fields/FullPathField.inc.php
@@ -61,7 +61,7 @@ class FullPathField extends DBFieldExpr @@ -61,7 +61,7 @@ class FullPathField extends DBFieldExpr
61 } 61 }
62 } 62 }
63 63
64 - public function appliesToContext($context) 64 + public function appliesToContext()
65 { 65 {
66 return ExprContext::DOCUMENT | ExprContext::FOLDER; 66 return ExprContext::DOCUMENT | ExprContext::FOLDER;
67 } 67 }
search2/search/search.inc.php
@@ -570,6 +570,11 @@ function processSearchExpression($query) @@ -570,6 +570,11 @@ function processSearchExpression($query)
570 570
571 $rs = $expr->evaluate(ExprContext::DOCUMENT); 571 $rs = $expr->evaluate(ExprContext::DOCUMENT);
572 $rs = $rs['docs']; 572 $rs = $rs['docs'];
  573 +
  574 + if(empty($rs)){
  575 + return array();
  576 + }
  577 +
573 usort($rs, 'rank_compare'); 578 usort($rs, 'rank_compare');
574 579
575 $results = array(); 580 $results = array();