Commit 4451bc816ff29d444b0bf4b615eb8486adfef5f0

Authored by Paul Barrett
1 parent 35c711e4

Removed call to checkValues function for fieldset queries.

Fixed

KTC-829: An advanced search for available fieldsets do not yield the desired document.

Committed by: Paul Barrett

Reviewed by: Jarrett Jordaan
Showing 1 changed file with 31 additions and 16 deletions
search2/search/expr.inc.php
... ... @@ -1387,8 +1387,8 @@ class SQLQueryBuilder implements QueryBuilder
1387 1387 // }
1388 1388 if ($this->used_tables['tag_words'] > 0)
1389 1389 {
1390   - $sql .= ' LEFT OUTER JOIN document_tags dt ON dt.document_id=d.id ' . "\n" .
1391   - ' LEFT OUTER JOIN tag_words tw ON dt.tag_id = tw.id ' . "\n";
  1390 + $sql .= ' LEFT OUTER JOIN document_tags dt ON dt.document_id=d.id ' . "\n"
  1391 + . ' LEFT OUTER JOIN tag_words tw ON dt.tag_id = tw.id ' . "\n";
1392 1392 }
1393 1393 }
1394 1394 else
... ... @@ -2399,7 +2399,18 @@ class OpExpr extends Expr
2399 2399  
2400 2400 // NOTE $oColumns = $oCriteria from calling function
2401 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?
  2402 + // At the very least this needs to have added:
  2403 + // 1. Correct verification of OR queries where one criterion fails
  2404 + // 2. Correct verification of NOT queries (simple type covered, complex type not covered, but probably will be done by OR in (1) above
  2405 + /**
  2406 + * This function attempts to verify that matches made on html type fields do not match only on html tags
  2407 + * but in fact match actual content.
  2408 + *
  2409 + * @param object $document_id
  2410 + * @param object $oColumns
  2411 + * @return boolean TRUE if match | FALSE if not
  2412 + */
  2413 + // NOTE this function is currently unused as it is incomplete and not able to handle some complex queries
2403 2414 public function checkValues($document_id, $oColumns)
2404 2415 {
2405 2416 foreach($oColumns as $column)
... ... @@ -2424,8 +2435,13 @@ class OpExpr extends Expr
2424 2435  
2425 2436 //$default->log->debug("POSITION: " . $position);
2426 2437  
2427   - if($position === false)
2428   - return false;
  2438 + if(!$column['not'] && ($position === false)) {
  2439 + return false;
  2440 + }
  2441 + // cater for NOT queries
  2442 + else if($column['not'] && ($position !== false)) {
  2443 + return false;
  2444 + }
2429 2445 }
2430 2446  
2431 2447 return true;
... ... @@ -2447,17 +2463,14 @@ class OpExpr extends Expr
2447 2463 $exprbuilder = new SQLQueryBuilder($this->getContext());
2448 2464 $exprbuilder->setIncludeStatus($this->incl_status);
2449 2465  
2450   - if (count($group) == 1)
2451   - {
  2466 + if (count($group) == 1) {
2452 2467 $sql = $exprbuilder->buildComplexQuery($group[0]);
2453 2468 }
2454   - else
2455   - {
  2469 + else {
2456 2470 $sql = $exprbuilder->buildSimpleQuery($op, $group);
2457 2471 }
2458 2472  
2459   - if (empty($sql))
2460   - {
  2473 + if (empty($sql)) {
2461 2474 return array();
2462 2475 }
2463 2476  
... ... @@ -2466,15 +2479,12 @@ class OpExpr extends Expr
2466 2479 $default->log->debug("SEARCH SQL: $sql");
2467 2480 $rs = DBUtil::getResultArray($sql);
2468 2481  
2469   - if (PEAR::isError($rs))
2470   - {
  2482 + if (PEAR::isError($rs)) {
2471 2483 throw new Exception($rs->getMessage());
2472 2484 }
2473 2485  
2474   - if (count($group) == 1)
2475   - {
  2486 + if (count($group) == 1) {
2476 2487 //$default->log->debug("CASE 1");
2477   -
2478 2488 $oCriteria = $this->checkComplexQuery($group[0]);
2479 2489 }
2480 2490 else
... ... @@ -2527,10 +2537,15 @@ class OpExpr extends Expr
2527 2537 {
2528 2538 if ($this->context == ExprContext::DOCUMENT)
2529 2539 {
  2540 + // NOTE removing the call to checkValues as the function only handles some query types, and is currently not so important as
  2541 + // we are stripping most html tags from the html type inputs
  2542 + /*
2530 2543 if((count($oCriteria) > 0 && $this->checkValues($id, $oCriteria)) || count($oCriteria) == 0)
2531 2544 {
2532 2545 $results[$id] = new DocumentResultItem($id, $rank, $item['title'], $exprbuilder->getResultText($item), null, $this->incl_status);
2533 2546 }
  2547 + */
  2548 + $results[$id] = new DocumentResultItem($id, $rank, $item['title'], $exprbuilder->getResultText($item), null, $this->incl_status);
2534 2549 }
2535 2550 else
2536 2551 {
... ...