Commit c5c0f6f288e9926775eb42f3700aed1ad9369227
1 parent
eae00bbb
Fixed search results - was returning no results for a query with more than one criterion
KTC-829. An advanced search for available fieldsets do not yield the desired document. Fixed Committed by: Paul Barrett
Showing
1 changed file
with
13 additions
and
19 deletions
search2/search/expr.inc.php
| @@ -2345,21 +2345,15 @@ class OpExpr extends Expr | @@ -2345,21 +2345,15 @@ class OpExpr extends Expr | ||
| 2345 | 2345 | ||
| 2346 | if (DefaultOpCollection::isBoolean($expr)) | 2346 | if (DefaultOpCollection::isBoolean($expr)) |
| 2347 | { | 2347 | { |
| 2348 | - //$query = '(' . $this->buildComplexQuery($left) . ' ' . $expr->op() . ' ' . $this->buildComplexQuery($right) . ')'; | ||
| 2349 | $iCriteria = $this->checkComplexQuery($left); | 2348 | $iCriteria = $this->checkComplexQuery($left); |
| 2350 | - if(!empty($iCriteria)) | ||
| 2351 | - //$oCriteria = $iCriteria; | ||
| 2352 | - $oCriteria[] = $iCriteria; | 2349 | + if(!empty($iCriteria)) { |
| 2350 | + $oCriteria = array_merge($oCriteria, $iCriteria); | ||
| 2351 | + } | ||
| 2353 | 2352 | ||
| 2354 | $iCriteria = $this->checkComplexQuery($right); | 2353 | $iCriteria = $this->checkComplexQuery($right); |
| 2355 | - if(!empty($iCriteria)) | ||
| 2356 | - //$oCriteria = array_merge($oCriteria, $iCriteria); | ||
| 2357 | - $oCriteria[] = $iCriteria; | ||
| 2358 | - | ||
| 2359 | - /*if ($expr->not()) | ||
| 2360 | - { | ||
| 2361 | - $query = "NOT $query"; | ||
| 2362 | - }*/ | 2354 | + if(!empty($iCriteria)) { |
| 2355 | + $oCriteria = array_merge($oCriteria, $iCriteria); | ||
| 2356 | + } | ||
| 2363 | } | 2357 | } |
| 2364 | else | 2358 | else |
| 2365 | { | 2359 | { |
| @@ -2379,13 +2373,11 @@ class OpExpr extends Expr | @@ -2379,13 +2373,11 @@ class OpExpr extends Expr | ||
| 2379 | { | 2373 | { |
| 2380 | $iCriteria = array(); | 2374 | $iCriteria = array(); |
| 2381 | 2375 | ||
| 2382 | - $iCriteria[0] = array(); | ||
| 2383 | - | ||
| 2384 | - $iCriteria[0]['field'] = $fieldname; | ||
| 2385 | - $iCriteria[0]['value'] = $value; | ||
| 2386 | - $iCriteria[0]['not'] = $expr->not(); | 2376 | + $iCriteria['field'] = $fieldname; |
| 2377 | + $iCriteria['value'] = $value; | ||
| 2378 | + $iCriteria['not'] = $expr->not(); | ||
| 2387 | 2379 | ||
| 2388 | - $oCriteria[] = $iCriteria[0]; | 2380 | + $oCriteria[] = $iCriteria; |
| 2389 | } | 2381 | } |
| 2390 | 2382 | ||
| 2391 | //global $default; | 2383 | //global $default; |
| @@ -2405,9 +2397,11 @@ class OpExpr extends Expr | @@ -2405,9 +2397,11 @@ class OpExpr extends Expr | ||
| 2405 | return $oCriteria; | 2397 | return $oCriteria; |
| 2406 | } | 2398 | } |
| 2407 | 2399 | ||
| 2400 | + // NOTE $oColumns = $oCriteria from calling function | ||
| 2401 | + // TODO variable name change? | ||
| 2402 | + // WHat is the purpose of this function, it seems to be a double check on the search results but why is this needed? | ||
| 2408 | public function checkValues($document_id, $oColumns) | 2403 | public function checkValues($document_id, $oColumns) |
| 2409 | { | 2404 | { |
| 2410 | - | ||
| 2411 | foreach($oColumns as $column) | 2405 | foreach($oColumns as $column) |
| 2412 | { | 2406 | { |
| 2413 | $rsField = DBUtil::getResultArray("SELECT df.name, dfl.value FROM documents d | 2407 | $rsField = DBUtil::getResultArray("SELECT df.name, dfl.value FROM documents d |