viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]
diff --git a/src/library/IndexShard.php b/src/library/IndexShard.php index 65cba7c81..97803f719 100644 --- a/src/library/IndexShard.php +++ b/src/library/IndexShard.php @@ -1123,26 +1123,24 @@ class IndexShard extends PersistentStructure implements CrawlConstants $doc_index = $doc_offset >> 4; $start = $start_offset >> 2; $end = $end_offset >> 2; - $extrema = ($is_ascending) ? $end : $start; - $post_doc_index = $this->getDocIndexOfPostingAtOffset($extrema); + $post_doc_index = $this->getDocIndexOfPostingAtOffset($end); if (($is_ascending && $doc_index > $post_doc_index) || (!$is_ascending && $doc_index < $post_doc_index)) { //fail fast return false; } else if ($doc_index == $post_doc_index) { - return [$extrema << 2, $post_doc_index << 4]; - } - if ($is_ascending) { - $current = $start; - $post_doc_index = $this->gallopPostingOffsetDocOffset($current, - $doc_index, $end, $direction); - } else { - $current = $end; - $post_doc_index = $this->gallopPostingOffsetDocOffset($current, - $doc_index, $start, $direction); + return [$end << 2, $post_doc_index << 4]; } + $current = $start; + $post_doc_index = $this->gallopPostingOffsetDocOffset($current, + $doc_index, $end, $direction); if ($doc_index == $post_doc_index) { return [$current << 2, $post_doc_index << 4]; } + if (!$is_ascending) { + $tmp = $end; + $end = $start; + $start = $tmp; + } return $this->binarySearchPostingOffsetDocOffset($start, $end, $current, $doc_index, $direction); } @@ -1196,7 +1194,7 @@ class IndexShard extends PersistentStructure implements CrawlConstants if ($high == $current) { return [$current << 2, $post_doc_index << 4]; } - $high = $current; + $low = $current; $current = (($low + $high) >> 1); } else { return [$current << 2, $post_doc_index << 4]; diff --git a/src/library/index_bundle_iterators/GroupIterator.php b/src/library/index_bundle_iterators/GroupIterator.php index 4bb2ee81b..b8b88891a 100644 --- a/src/library/index_bundle_iterators/GroupIterator.php +++ b/src/library/index_bundle_iterators/GroupIterator.php @@ -442,7 +442,7 @@ class GroupIterator extends IndexBundleIterator } else { $this->num_docs = floor( - ($this->seen_docs*$this->index_bundle_iterator->num_docs)/ + ($this->seen_docs * $this->index_bundle_iterator->num_docs)/ $this->seen_docs_unfiltered); } } else { diff --git a/src/library/index_bundle_iterators/IntersectIterator.php b/src/library/index_bundle_iterators/IntersectIterator.php index 3d9936267..0704fca81 100644 --- a/src/library/index_bundle_iterators/IntersectIterator.php +++ b/src/library/index_bundle_iterators/IntersectIterator.php @@ -236,7 +236,7 @@ class IntersectIterator extends IndexBundleIterator } } } - $this->count_block = (empty($docs)) ? 0 : count($docs); + $this->count_block = (empty($docs) || $docs < 0) ? 0 : count($docs); $this->pages = $docs; return $docs; } @@ -439,7 +439,6 @@ class IntersectIterator extends IndexBundleIterator } $last_changed = -1; $i = 0; - $j = 0; while($i != $last_changed) { if (time() > $time_out) { return -1; @@ -464,7 +463,6 @@ class IntersectIterator extends IndexBundleIterator $i = 0; $last_changed = max($last_changed, 0); } - $j++; } return 1; } @@ -506,7 +504,8 @@ class IntersectIterator extends IndexBundleIterator * @return mixed an array with the desired document offset * and generation; -1 on fail */ - public function currentGenDocOffsetWithWord() { + public function currentGenDocOffsetWithWord() + { $this->syncGenDocOffsetsAmongstIterators(); return $this->index_bundle_iterators[0]->currentGenDocOffsetWithWord(); } diff --git a/src/library/index_bundle_iterators/WordIterator.php b/src/library/index_bundle_iterators/WordIterator.php index e5920a5ee..b85c7ec80 100644 --- a/src/library/index_bundle_iterators/WordIterator.php +++ b/src/library/index_bundle_iterators/WordIterator.php @@ -319,14 +319,17 @@ class WordIterator extends IndexBundleIterator $this->last_offset)); $delta_sign = 1; } else { - $total_guess = IndexShard::numDocsOrLinks($this->next_offset, - $this->start_offset); + $total_guess = IndexShard::numDocsOrLinks($this->start_offset, + $this->next_offset); $num_docs = $total_guess % $this->results_per_block; if ($num_docs == 0) { $num_docs = $this->results_per_block; } else { $num_docs = IndexShard::numDocsOrLinks($this->start_offset, $this->last_offset) % $this->results_per_block; + if ($num_docs == 0) { + $num_docs = $this->results_per_block; + } } $delta_sign = -1; } @@ -390,8 +393,13 @@ class WordIterator extends IndexBundleIterator $offset_pair; } } - $this->seen_docs = ($this->current_offset - $this->start_offset) / - IndexShard::POSTING_LEN; + if ($is_ascending) { + $this->seen_docs = ($this->current_offset - $this->start_offset) / + IndexShard::POSTING_LEN; + } else { + $this->seen_docs = ($this->last_offset - $this->current_offset) / + IndexShard::POSTING_LEN; + } } /** * Forwards the iterator one group of docs. This is what's called @@ -399,9 +407,9 @@ class WordIterator extends IndexBundleIterator */ public function plainAdvance() { + $is_ascending = ($this->direction == self::ASCENDING); $this->advanceSeenDocs(); $this->current_doc_offset = null; - $is_ascending = ($this->direction == self::ASCENDING); $update_check = ($is_ascending) ? ($this->current_offset < $this->next_offset) : ($this->current_offset > $this->next_offset); diff --git a/src/library/media_jobs/FeedsUpdateJob.php b/src/library/media_jobs/FeedsUpdateJob.php index 791592618..3aa964092 100644 --- a/src/library/media_jobs/FeedsUpdateJob.php +++ b/src/library/media_jobs/FeedsUpdateJob.php @@ -642,6 +642,16 @@ class FeedsUpdateJob extends MediaJob $i = 0; $term_counts = []; $seen_url_count = 0; + usort($items, function($i1, $i2) { + $pub1 = (empty($i1['PUBDATE'])) ? time() : + $i1['PUBDATE']; + $pub2 = (empty($i2['PUBDATE'])) ? time() : + $i2['PUBDATE']; + if ($pub1 == $pub2) { + return 0; + } + return ($pub1 < $pub2) ? -1 : 1; + }); foreach ($items as $item) { L\crawlTimeoutLog( "----..have added %s items to new item index.", $i);