protected function searchInternal( $term, $fulltext ) {
		global $wgCountTotalSearchHits;
		
		$results = DumpReader::index_search($term);

		return new Bz2SearchResultSet( $results, $term);
	}
 function select($table, $fields, $conds = '', $fname = 'DatabaseBase::select', $options = array())
 {
     $row = array();
     $title = false;
     if (isset($conds['page_title'])) {
         $title = $conds['page_title'];
         if ($conds['page_namespace'] && MWNamespace::getCanonicalName($conds['page_namespace'])) {
             $title = MWNamespace::getCanonicalName($conds['page_namespace']) . ':' . $title;
         }
     }
     if ($title && ($table == 'page' || is_array($table) && in_array('page', $table))) {
         if (preg_match('/Template:Pp-/i', $title)) {
             return false;
         }
         $textid = CachedStorage::fetchIdByTitle($title);
         if (!$textid) {
             $content = DumpReader::load_article($title);
             if (!$content) {
                 wfDebug('no content for ' . $title);
                 return false;
             }
             $textid = CachedStorage::set($title, $content);
         }
     } elseif (isset($conds['rev_id'])) {
         $textid = $conds['rev_id'];
     }
     if (!isset($textid)) {
         return $this->resultObject(array());
     }
     if ($table == 'page') {
         // Given a page_title, get the id of text content.  For efficiency,
         //	we fetch the text and store it by ID to access in case 2.
         $row = array_fill_keys($fields, '');
         $row['page_id'] = $textid;
         $row['page_title'] = $title;
         $row['page_latest'] = $textid;
     } elseif ($table == array('page', 'revision')) {
         // Redundantly return textid which is cache key to article wml.
         $fields[] = 'rev_user';
         $fields[] = 'rev_user_text';
         $row = array_fill_keys($fields, '');
         $row['rev_id'] = $textid;
         $row['rev_text_id'] = $textid;
     } else {
         print_r($table);
         print_r($conds);
     }
     return $this->resultObject($row);
 }
	function runTests() {
		global $wgOut, $wgTitle;

		$wgOut->wrapWikiMsg('<h1>$1</h1>', 'offline_heading_status');

		$wgOut->addHTML('<ul>');
		// lookup a real article in the index can be searched
		$results = DumpReader::index_search(wfMsg('offline_test_article'));
		if (count($results) > 0)
			list ($bz_file, $offset, $entry_title) = $results[0];

		$test_index = isset($bz_file);
		$this->printTest($test_index, 'offline_index_test');
		if (!$test_index) {
			$this->diagnoseIndex();
			return;
		}

		// tests that bz2 dumpfiles can be opened and read
		$xml = DumpReader::load_bz($bz_file, $entry_title);
		$test_bz = isset($xml);
		$this->printTest($test_bz, 'offline_bzload_test');
		if (!$test_bz) {
			$this->diagnoseBzload($bz_file);
			return;
		}
			//report subdirectory setting
//                if (substr($bz_file, 0, 1) == 'x') {
//                    $subdir = dirname($bz_file); //TODO strip absolute components if needed
//                    $wgOut->addWikiMsg('offline_subdir-status', $subdir);
//                    $wgOut->addHTML(
//                        '<label>' .  wfMsg('offline_change-subdir') .
//                        '<input type=text size=20 name="subdir" value="'.$subdir.'">
//                        <input type=submit name="subdir" value="Change">
//                        </label/>'
//                    );
//                }

		// TODO report language settings and availabilities

		//test that a specific article can be loaded
		$article_wml = DumpReader::load_article($entry_title);
		$test_article = isset($article_wml);
		$this->printTest($test_article, 'offline_article_test');
		if (!$test_article) {
			//TODO diagnose
			return;
		}
		//TODO test that the wml has not been padded or truncated

		//test that our handler is still hooked in
		$mw_api_article = new Article(Title::newFromText($entry_title));
		$mw_api_article->loadContent();
		$content = $mw_api_article->getContent();
//wfDebug('got '.strlen($mw_api_article->mContent).' bytes of wml from cache');
		$test_hooks = $mw_api_article->mContentLoaded;
		// TODO false positive
		$this->printTest($test_hooks, 'offline_hooks_test');
		if (!$test_hooks) {
			$this->diagnoseHooks();
			return;
		}

		//TODO test Templates

		$wgOut->addHTML('</ul>');

		$wgOut->wrapWikiMsg('<i>$1</i>', 'offline_all_tests_pass');
		//TODO div collapse or load on demand
		//$wgOut->addWikiText($content);
	}