get rid of getSnippet offset notice, a=chris
get rid of getSnippet offset notice, a=chris
diff --git a/lib/btree.php b/lib/btree.php
index 3554c5128..682768d3f 100644
--- a/lib/btree.php
+++ b/lib/btree.php
@@ -116,7 +116,8 @@ class BTree
$node = unserialize(file_get_contents($node_file));
return $node;
} else {
- exit("Could not read node $id from disk");
+ crawlLog("Btree could not read node $id from disk");
+ return false;
}
}
@@ -149,7 +150,9 @@ class BTree
$node_file = $this->dir."/$id.txt";
if(file_exists($node_file)) {
unlink($node_file);
- } else exit("Could not delete node $id from disk");
+ } else {
+ crawlLog("Could not delete node $id from disk");
+ }
}
/**
diff --git a/models/model.php b/models/model.php
index 719f960ea..7cef97826 100755
--- a/models/model.php
+++ b/models/model.php
@@ -281,14 +281,12 @@ class Model implements CrawlConstants
sort($word_locations);
foreach($word_locations as $pos) {
if($pos < $high) continue;
- $pre_low = ($pos >= SNIPPET_LENGTH_LEFT) ?
- $pos - SNIPPET_LENGTH_LEFT: 0;
+ $pre_low = max($pos - SNIPPET_LENGTH_LEFT, 0);
$low = mb_stripos($text_source, " ", $pre_low);
if($low > $pos) {
$low = $pre_low;
}
- $pre_high = ($pos + SNIPPET_LENGTH_RIGHT <= $len ) ?
- $pos + SNIPPET_LENGTH_RIGHT: $len;
+ $pre_high = min($pos + SNIPPET_LENGTH_RIGHT, $len);
$high = mb_stripos($text_source, " ",
max(min($pre_high - 10, 0), min($pos, $len)));
if($high > $pre_high + 10){