Modifies code for declaring an index to be no_network to fix a bug in stats line, a=chris
Modifies code for declaring an index to be no_network to fix a bug in stats line, a=chris
diff --git a/controllers/search_controller.php b/controllers/search_controller.php
index 47c7819d4..31faa79c8 100755
--- a/controllers/search_controller.php
+++ b/controllers/search_controller.php
@@ -347,10 +347,7 @@ class SearchController extends Controller implements CrawlConstants
$use_cache_if_possible = ($original_query == $query) ? true : false;
$index_archive_name= self::index_data_base_name.$index_name;
- if(file_exists( CRAWL_DIR."/cache/$index_archive_name/no_network.txt")){
- $_REQUEST['network'] = false;
- //if default index says no network queries then no network queries
- }
+
if(!isset($_REQUEST['network']) || $_REQUEST['network'] == "true") {
$queue_servers = $this->machineModel->getQueueServerUrls();
if($queue_servers != array() && file_exists(
diff --git a/models/crawl_model.php b/models/crawl_model.php
index 87fdc3d8b..bd6c935f6 100755
--- a/models/crawl_model.php
+++ b/models/crawl_model.php
@@ -575,7 +575,8 @@ EOT;
*/
function getCrawlSeedInfo($timestamp, $machine_urls = NULL)
{
- if($machine_urls != NULL && !$this->isSingleLocalhost($machine_urls)) {
+ if($machine_urls != NULL &&
+ !$this->isSingleLocalhost($machine_urls, $timestamp)) {
/* seed info should be same amongst all queue_servers that have it--
only start schedule differs -- however, not all queue_servers
necessarily have the same crawls. THus, we still query all
@@ -643,7 +644,8 @@ EOT;
*/
function setCrawlSeedInfo($timestamp, $new_info, $machine_urls = NULL)
{
- if($machine_urls != NULL && !$this->isSingleLocalhost($machine_urls)) {
+ if($machine_urls != NULL &&
+ !$this->isSingleLocalhost($machine_urls, $timestamp)) {
$params = array($timestamp, $new_info);
$this->execMachines("setCrawlSeedInfo",
$machine_urls, serialize($params));
@@ -702,7 +704,7 @@ EOT;
$info['IS_MIX'] = true;
} else {
if($machine_urls != NULL &&
- !$this->isSingleLocalhost($machine_urls)) {
+ !$this->isSingleLocalhost($machine_urls, $timestamp)) {
if(!in_array(NAME_SERVER, $machine_urls)) {
array_unshift($machine_urls, NAME_SERVER);
}
@@ -759,7 +761,8 @@ EOT;
*/
function deleteCrawl($timestamp, $machine_urls)
{
- if($machine_urls != NULL && !$this->isSingleLocalhost($machine_urls)) {
+ if($machine_urls != NULL &&
+ !$this->isSingleLocalhost($machine_urls, $timestamp)) {
//get rid of cache info on Name machine
$mask = CRAWL_DIR."/cache/".self::network_crawllist_base_name.
"*.txt";
@@ -1238,7 +1241,8 @@ EOT;
function injectUrlsCurrentCrawl($timestamp, $inject_urls,
$machine_urls = NULL)
{
- if($machine_urls != NULL && !$this->isSingleLocalhost($machine_urls)) {
+ if($machine_urls != NULL &&
+ !$this->isSingleLocalhost($machine_urls, $timestamp)) {
$this->execMachines("injectUrlsCurrentCrawl", $machine_urls,
serialize(array($timestamp, $inject_urls)));
return;
diff --git a/models/model.php b/models/model.php
index ffecec945..86ad8d8fe 100755
--- a/models/model.php
+++ b/models/model.php
@@ -328,11 +328,20 @@ class Model implements CrawlConstants
*
* @param array $machine_urls urls of yioop instances to which the action
* applies
+ * @param string $index_timestamp if timestamp exists checks if the index
+ * has declared itself to be a no network index.
* @return bool whether it involves a single local yioop instance (true)
* or not (false)
*/
- function isSingleLocalhost($machine_urls)
+ function isSingleLocalhost($machine_urls, $index_timestamp = -1)
{
+ if($index_timestamp >= 0) {
+ $index_archive_name= self::index_data_base_name.$index_timestamp;
+ if(file_exists(
+ CRAWL_DIR."/cache/$index_archive_name/no_network.txt")){
+ return true;
+ }
+ }
return count($machine_urls) <= 1 &&
UrlParser::isLocalhostUrl($machine_urls[0]);
}