Skip to content

Commit

Permalink
Added a space after the ALL of the search queries as a temp workaroun…
Browse files Browse the repository at this point in the history
…d of searching for non-Roman characters

Fixed the Related Post widget from adding a query when it should not be

Fixed stats cron file location
  • Loading branch information
bauerjj committed Aug 25, 2012
1 parent 8405f76 commit 64e614b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 17 deletions.
9 changes: 5 additions & 4 deletions class.sphinxsearch.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function __construct() {
$this->Settings = $Settings->GetAllSettings();
//create subclasses
$this->_Storage = new SplObjectStorage();

if ($this->Settings['Status']->SearchdRunning && $this->Settings['Status']->EnableSphinxSearch) { //check if sphinx is running and if not manually overriden
//if($this->Settings['Status']->SearchdRunning && $this->Settings['Status']->EnableSphinxSearch) //check if sphinx is running and if not manually overriden
if (1) {
//If so, register the widgets
$this->RegisterWidgets();
$this->RegisterModules();
Expand Down Expand Up @@ -155,6 +155,7 @@ private function RunSearch($Sender = FALSE) {
if (sizeof($this->Queries) == 0)
return $FinalResults; //don't run queries since no queries qued up
else if ($this->Settings['Status']->SearchdRunning) {
//print_r($this->Queries); die;
$Results = $this->SphinxClient->RunQueries(); //perform all of the queries
//print_r($Results); die;
if ($Results) {
Expand Down Expand Up @@ -224,9 +225,9 @@ public function Controller_ViewFile($Sender) {
else if ($_GET['file'] == 'cronlog')
$File = PATH_PLUGINS . DS . 'SphinxSearch' . DS . 'cron' . DS . 'sphinx_cron.log';
else if ($_GET['file'] == 'querylog')
$File = $this->Settings['Status']->QueryPath;
$File = $this->Settings['Install']->QueryPath;
else if ($_GET['file'] == 'searchlog')
$File = $this->Settings['Status']->LogPath;
$File = $this->Settings['Install']->LogPath;
if (!isset($File)) {
echo 'An error has occured';
return;
Expand Down
2 changes: 1 addition & 1 deletion class.sphinxsearchinstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function SetupCron() {
if (!file_put_contents($CronFolder . DS . 'cron.reindex.delta.php', $ReWritedDelta)) {
parent::Update(SS_FATAL_ERROR, FALSE, FALSE, "Error writing cron file: $DeltaTemplate");
}
if (!file_put_contents($CronFolder . DS . 'cron.reindex.stats.php', $ReWritedMain)) {
if (!file_put_contents($CronFolder . DS . 'cron.reindex.stats.php', $ReWritedStats)) {
parent::Update(SS_FATAL_ERROR, FALSE, FALSE, "Error writing cron file: $StatsTemplate");
}
} catch (Exception $e) {
Expand Down
9 changes: 8 additions & 1 deletion views/sphinxsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,17 @@ function waitForMsg(){
<br/>

<h3>Changelog</h3>
2012XXXX
<ol>
<li>Created temporary workaround that fixed non-Roman search phrases from being executed correctly </li>
<li>Fixed stats cron file location to its actual location</li>
<li>Fixed the RelatedPost widget from adding a query when it should not be</li>
</ol>
<br/>
20120807
<ol>
<li>Added debug table to control panel</li>
<li>Fixed cron files to index at common times</li>
<li>Fixed cron files to index at common times - also corrected file paths and comments</li>
<li>Deleted "Reload Connections" button...it was useless</li>
</ol>
<br/>
Expand Down
2 changes: 1 addition & 1 deletion widgets/class.widget.member.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function AddQuery($Sender, $Options = FALSE) {
$Query = $MemberName;

$Search = $this->FieldSearch($Query, array(SS_FIELD_USERNAME));
$QueryIndex = $this->SphinxClient->AddQuery($Search, $Index = SS_INDEX_DIST, $this->Name);
$QueryIndex = $this->SphinxClient->AddQuery($Search.' ', $Index = SS_INDEX_DIST, $this->Name);

$this->Queries[] = array(
'Name' => $this->Name,
Expand Down
2 changes: 1 addition & 1 deletion widgets/class.widget.relateddiscussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function AddQuery($Sender, $Options = FALSE) {
$this->SphinxClient->SetLimits(1, $this->Settings['Admin']->LimitRelatedThreadsSidebarDiscussion); //notice the offset of '1'. This is so don't select current viewed discussion as related
$Thread = $Sender->Discussion->Name; //get the discussion name (thread topic) to search against
$Query = $this->FieldSearch($this->OperatorOrSearch($Thread), array(SS_FIELD_TITLE));
$QueryIndex = $this->SphinxClient->AddQuery($Query, $Index = SS_INDEX_DIST, $this->Name);
$QueryIndex = $this->SphinxClient->AddQuery($Query.' ', $Index = SS_INDEX_DIST, $this->Name);

$this->Queries[] = array(
'Name' => $this->Name,
Expand Down
4 changes: 2 additions & 2 deletions widgets/class.widget.relatedmain.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function AddQuery($Sender, $Options = FALSE) {
//must first clear any special characters in query string if using the extended syntax
//@todo probably better to use the 'words' index
$Query = $this->FieldSearch($this->OperatorOrSearch($this->ClearFromTags($Sanitized['Query'])), array(SS_FIELD_TITLE));

$QueryIndex = $this->SphinxClient->AddQuery($Query, $Index = SS_INDEX_DIST, $this->Name);
//echo $Query; die;
$QueryIndex = $this->SphinxClient->AddQuery($Query.' ', $Index = SS_INDEX_DIST, $this->Name);
$this->Queries[] = array(
'Name' => $this->Name,
'Index' => $QueryIndex,
Expand Down
4 changes: 2 additions & 2 deletions widgets/class.widget.relatedpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function Update(SplSubject $Subject) {
*/
public function AddQuery($Sender, $Options = FALSE) {
$Thread = GetValue('Query', $Options); //get the discussion name (thread topic) to search against
if ($Options) { //call this directly from handler: Controller_newdiscussion
if ($Thread) { //call this directly from handler: Controller_newdiscussion
$this->SphinxClient->ResetFilters();
$this->SphinxClient->ResetGroupBy();
$this->SphinxClient->SetLimits(0, $this->Settings['Admin']->LimitRelatedThreadsPost);

$Query = $this->FieldSearch($this->OperatorOrSearch($Thread), array(SS_FIELD_TITLE));
$QueryIndex = $this->SphinxClient->AddQuery($Query, $Index = SS_INDEX_DIST, $this->Name);
$QueryIndex = $this->SphinxClient->AddQuery($Query.' ', $Index = SS_INDEX_DIST, $this->Name);
$this->Queries[] = array(
'Name' => $this->Name,
'Index' => $QueryIndex,
Expand Down
4 changes: 2 additions & 2 deletions widgets/class.widget.stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public function AddQuery($Sender, $Options = FALSE) {
$Sanitized = $this->ValidateInputs(); //get the submitted query
$Query = $this->OperatorOrSearch($Sanitized['Query']); // vanilla | forums | search


$QueryIndex = $this->SphinxClient->AddQuery('@(keywords) ' . $Query, $Index = SS_INDEX_STATS, 'Related Searches');
//echo $Query; die;
$QueryIndex = $this->SphinxClient->AddQuery('@(keywords) ' . $Query.' ', $Index = SS_INDEX_STATS, 'Related Searches');

$this->Queries[] = array(
'Name' => $this->NameRSearches,
Expand Down
15 changes: 12 additions & 3 deletions widgets/class.widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,27 @@ protected function ValidateInputs() {

$QueryIn = trim(filter_input(INPUT_GET, 'Search', FILTER_SANITIZE_STRING)); //probably overkill
$QueryIn = explode(' ', $QueryIn);
$Match = filter_input(INPUT_GET, 'match', FILTER_SANITIZE_STRING);
foreach ($QueryIn as $Word) { //get rid of any white spaces inbetween words
if (!is_string($Word) || $Word == '')
continue;
if ($Query == '')
if ($Query == '') {
if ($Match != 'Extended') {
//$Word = $this->SphinxClient->EscapeString($Word);
}
$Query = $Word;
else
}
else{
if ($Match != 'Extended') {
//$Word = $this->SphinxClient->EscapeString($Word);
//$Query = $Word;
}
$Query .= ' ' . $Word;
}
}

$TitlesOnly = (filter_input(INPUT_GET, 'titles', FILTER_SANITIZE_NUMBER_INT) == 1 ? 1 : 0); //checkbox - bool
$WithReplies = (filter_input(INPUT_GET, 'WithReplies', FILTER_SANITIZE_NUMBER_INT) == 1 ? 1 : 0); //checkbox - bool
$Match = filter_input(INPUT_GET, 'match', FILTER_SANITIZE_STRING);
$Child = (filter_input(INPUT_GET, 'child', FILTER_SANITIZE_NUMBER_INT) == 1 ? 1 : 0); //checkbox - bool
if (isset($_GET['forums']) && is_array($_GET['forums'])) {
foreach ($_GET['forums'] as $Forum) {
Expand Down

0 comments on commit 64e614b

Please sign in to comment.