Fixes a bug in using Settings to select a crawl mix, a=chris

Chris Pollett [2013-04-03 20:Apr:rd]
Fixes a bug in using Settings to select a crawl mix, a=chris
Filename
controllers/admin_controller.php
controllers/search_controller.php
lib/archive_bundle_iterators/database_bundle_iterator.php
lib/index_bundle_iterators/doc_iterator.php
lib/page_rule_parser.php
models/datasources/pdo_manager.php
diff --git a/controllers/admin_controller.php b/controllers/admin_controller.php
index dd202f5f2..2e4935c8e 100755
--- a/controllers/admin_controller.php
+++ b/controllers/admin_controller.php
@@ -1150,8 +1150,6 @@ class AdminController extends Controller implements CrawlConstants
         return $data;
     }

-
-
     /**
      * Converts an array of lines of strings into a single string with
      * proper newlines, each line having been trimmed and potentially
diff --git a/controllers/search_controller.php b/controllers/search_controller.php
index aca296eea..bde1727ce 100755
--- a/controllers/search_controller.php
+++ b/controllers/search_controller.php
@@ -374,7 +374,7 @@ class SearchController extends Controller implements CrawlConstants

         $current_its = $this->crawlModel->getCurrentIndexDatabaseName();
         $index_timestamp = $this->getIndexTimestamp();
-
+        $is_mix = false;
         if($index_timestamp != $current_its) {
             if($raw != 1) {
                 if($index_timestamp != 0 ) {
@@ -382,7 +382,6 @@ class SearchController extends Controller implements CrawlConstants
                     //(some crawlers replay deleted crawls)
                     $crawls = $this->crawlModel->getCrawlList(false, true,
                         $machine_urls, true);
-                    $is_mix = false;
                     if($this->crawlModel->isCrawlMix($index_timestamp)) {
                         $is_mix = true;
                     }
@@ -398,23 +397,18 @@ class SearchController extends Controller implements CrawlConstants
                         unset($_SESSION['its']);
                         include(BASE_DIR."/error.php");
                         exit();
-                    } else if(!$found_crawl) {
+                    } else if(!$found_crawl && !$is_mix) {
                         unset($_SESSION['its']);
                         $index_timestamp = $current_its;
                     }
-                } else {
-                    $index_timestamp = $current_its;
-                        //use the default crawl index
                 }
             }
         }
-
-        $index_info = false;
-        if($web_flag && $index_timestamp != 0 ) {
+        if($web_flag && $index_timestamp != 0) {
             $index_info =  $this->crawlModel->getInfoTimestamp(
                 $index_timestamp, $machine_urls);
-            if($index_info == array() || !isset($index_info["COUNT"]) ||
-                $index_info["COUNT"] == 0) {
+            if($index_info == array() || ((!isset($index_info["COUNT"]) ||
+                $index_info["COUNT"] == 0) && !$is_mix)) {
                 if($index_timestamp != $current_its) {
                     $index_timestamp = $current_its;
                     $index_info =  $this->crawlModel->getInfoTimestamp(
@@ -1241,7 +1235,7 @@ class SearchController extends Controller implements CrawlConstants
      * @param string $url to get cached page for
      * @param array $ui_flags array of  ui features which
      *      should be added to the cache page. For example, "highlight"
-     *      would way search terms should be highlighted, "history_ui"
+     *      would way search terms should be highlighted, "history"
      *      says add history navigation for all copies of this cache page in
      *      yioop system.
      * @param string $terms space separated list of search terms
diff --git a/lib/archive_bundle_iterators/database_bundle_iterator.php b/lib/archive_bundle_iterators/database_bundle_iterator.php
index fff1ec533..90c486ac5 100644
--- a/lib/archive_bundle_iterators/database_bundle_iterator.php
+++ b/lib/archive_bundle_iterators/database_bundle_iterator.php
@@ -126,10 +126,10 @@ class DatabaseBundleIterator extends ArchiveBundleIterator
            $this->field_value_separator = "\n----\n";
         }

-        if(isset($ini['record_separator'])) {
-            $this->record_separator = $ini['record_separator'];
+        if(isset($ini['column_separator'])) {
+            $this->column_separator = $ini['column_separator'];
         } else {
-           $this->record_separator = "\n====\n";
+           $this->column_separator = "\n====\n";
         }

         if(isset($ini['encoding'])) {
@@ -191,8 +191,8 @@ class DatabaseBundleIterator extends ArchiveBundleIterator
         while($row = $db->fetchArray($result)) {
             $page = "";
             foreach($row as $key => $value) {
-                $page .= "$key\n{$this->field_value_separator}\n".
-                    "$value\n{$this->record_separator}\n";
+                $page .= "$key{$this->field_value_separator}".
+                    "$value{$this->column_separator}";
             }
             if($no_process) {
                 $pages[] = $page;
diff --git a/lib/index_bundle_iterators/doc_iterator.php b/lib/index_bundle_iterators/doc_iterator.php
index 8eb0ff779..5e2683332 100755
--- a/lib/index_bundle_iterators/doc_iterator.php
+++ b/lib/index_bundle_iterators/doc_iterator.php
@@ -133,7 +133,8 @@ class DocIterator extends IndexBundleIterator
         $info = $index->getArchiveInfo($index->dir_name);

         $this->num_docs = $info['COUNT'];
-        $this->num_generations = $index->generation_info['ACTIVE'] + 1;
+        $this->num_generations = (isset($index->generation_info['ACTIVE'])) ?
+            $index->generation_info['ACTIVE'] + 1 : 0;

         $this->current_block_fresh = false;

diff --git a/lib/page_rule_parser.php b/lib/page_rule_parser.php
index befa3f4c3..bb038e1f6 100644
--- a/lib/page_rule_parser.php
+++ b/lib/page_rule_parser.php
@@ -43,13 +43,16 @@ require_once BASE_DIR."/lib/crawl_constants.php";
  * There are two types of statements that a user can define:
  * command statements and assignment statements
  *
- * A command statement takes a field argument for the page associative
- * and that array and does a function call to manipulate that page.
- * Right now the two supported commands are to unset that field value,
- * and to add the field and field value to the META_WORD array for the page
+ * A command statement takes a key field argument for the page associative array
+ * and does a function call to manipulate that page. Right now the supported
+ * commands are to unset that field value, to add the field and field value to
+ * the META_WORD array for the page and to split the field on comma, view this
+ * as a search keywords => link text association, and add this the
+ * KEYWORD_LINKS array.
  * These have the syntax:
  * unset(field)
  * addMetaWords(field)
+ * addKeywordLink(field)
  *
  * Assignments can either be straight assignments with '=' or concatenation
  * assignments with '.='. There are three kinds of values that one can assign:
diff --git a/models/datasources/pdo_manager.php b/models/datasources/pdo_manager.php
index cc319ba52..1114cfd63 100644
--- a/models/datasources/pdo_manager.php
+++ b/models/datasources/pdo_manager.php
@@ -104,7 +104,6 @@ class PdoManager extends DatasourceManager
             $this->num_affected = 0;
         } else {
             $this->num_affected = $this->pdo->exec($sql);
-echo $this->num_affected ;
             $result = $this->num_affected + 1;
         }
         return $result;
ViewGit