aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search
diff options
context:
space:
mode:
authorDhruv Goel <dhruv.goel92@gmail.com>2012-07-10 05:51:52 +0530
committerDhruv <dhruv.goel92@gmail.com>2012-07-19 23:01:37 +0530
commitfdb7e64e29d7b6286b505cf3a75fe53cfdfc7503 (patch)
tree4ca83a0b2484e847f0fb14ed5f74554a52713bf6 /phpBB/includes/search
parent537a16220ea9561332a17004eec79f2854c68df4 (diff)
downloadforums-fdb7e64e29d7b6286b505cf3a75fe53cfdfc7503.tar
forums-fdb7e64e29d7b6286b505cf3a75fe53cfdfc7503.tar.gz
forums-fdb7e64e29d7b6286b505cf3a75fe53cfdfc7503.tar.bz2
forums-fdb7e64e29d7b6286b505cf3a75fe53cfdfc7503.tar.xz
forums-fdb7e64e29d7b6286b505cf3a75fe53cfdfc7503.zip
[feature/sphinx-fulltext-search] fix comments
PHPBB3-10946
Diffstat (limited to 'phpBB/includes/search')
-rw-r--r--phpBB/includes/search/fulltext_sphinx.php34
-rw-r--r--phpBB/includes/search/sphinx/config.php52
-rw-r--r--phpBB/includes/search/sphinx/config_section.php6
3 files changed, 53 insertions, 39 deletions
diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php
index 1ff6ab21b5..c72db1862e 100644
--- a/phpBB/includes/search/fulltext_sphinx.php
+++ b/phpBB/includes/search/fulltext_sphinx.php
@@ -116,7 +116,7 @@ class phpbb_search_fulltext_sphinx
return $error;
}
- // move delta to main index each hour
+ // Move delta to main index each hour
set_config('search_gc', 3600);
return false;
@@ -135,8 +135,9 @@ class phpbb_search_fulltext_sphinx
include ($phpbb_root_path . 'config.' . $phpEx);
- // now that we're sure everything was entered correctly, generate a config for the index
- // we misuse the avatar_salt for this, as it should be unique ;-)
+ /* Now that we're sure everything was entered correctly,
+ generate a config for the index. We misuse the avatar_salt
+ for this, as it should be unique. */
$config_object = new phpbb_search_sphinx_config($this->config['fulltext_sphinx_config_path'] . 'sphinx.conf');
$config_data = array(
@@ -396,7 +397,7 @@ class phpbb_search_fulltext_sphinx
}
}
- // most narrow filters first
+ // Most narrow filters first
if ($topic_id)
{
$this->sphinx->SetFilter('topic_id', array($topic_id));
@@ -407,31 +408,37 @@ class phpbb_search_fulltext_sphinx
switch($fields)
{
case 'titleonly':
- // only search the title
+ // Only search the title
if ($terms == 'all')
{
$search_query_prefix = '@title ';
}
- $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); // weight for the title
- $this->sphinx->SetFilter('topic_first_post', array(1)); // 1 is first_post, 0 is not first post
+ // Weight for the title
+ $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1));
+ // 1 is first_post, 0 is not first post
+ $this->sphinx->SetFilter('topic_first_post', array(1));
break;
case 'msgonly':
- // only search the body
+ // Only search the body
if ($terms == 'all')
{
$search_query_prefix = '@data ';
}
- $this->sphinx->SetFieldWeights(array("title" => 1, "data" => 5)); // weight for the body
+ // Weight for the body
+ $this->sphinx->SetFieldWeights(array("title" => 1, "data" => 5));
break;
case 'firstpost':
- $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); // more relative weight for the title, also search the body
- $this->sphinx->SetFilter('topic_first_post', array(1)); // 1 is first_post, 0 is not first post
+ // More relative weight for the title, also search the body
+ $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1));
+ // 1 is first_post, 0 is not first post
+ $this->sphinx->SetFilter('topic_first_post', array(1));
break;
default:
- $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); // more relative weight for the title, also search the body
+ // More relative weight for the title, also search the body
+ $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1));
break;
}
@@ -458,7 +465,8 @@ class phpbb_search_fulltext_sphinx
$this->sphinx->SetLimits($start, (int) $per_page, SPHINX_MAX_MATCHES);
$result = $this->sphinx->Query($search_query_prefix . str_replace('&quot;', '"', $this->search_query), $this->indexes);
- // could be connection to localhost:3312 failed (errno=111, msg=Connection refused) during rotate, retry if so
+ /* Could be connection to localhost:3312 failed (errno=111,
+ msg=Connection refused) during rotate, retry if so */
$retries = SPHINX_CONNECT_RETRIES;
while (!$result && (strpos($this->sphinx->_error, "errno=111,") !== false) && $retries--)
{
diff --git a/phpBB/includes/search/sphinx/config.php b/phpBB/includes/search/sphinx/config.php
index 966cd0f284..3820eff178 100644
--- a/phpBB/includes/search/sphinx/config.php
+++ b/phpBB/includes/search/sphinx/config.php
@@ -49,7 +49,7 @@ class phpbb_search_sphinx_config
{
for ($i = 0, $size = sizeof($this->sections); $i < $size; $i++)
{
- // make sure this is really a section object and not a comment
+ // Make sure this is really a section object and not a comment
if (($this->sections[$i] instanceof phpbb_search_sphinx_config_section) && $this->sections[$i]->get_name() == $name)
{
return $this->sections[$i];
@@ -76,7 +76,7 @@ class phpbb_search_sphinx_config
*/
function read($filename)
{
- // split the file into lines, we'll process it line by line
+ // Split the file into lines, we'll process it line by line
$config_file = file($filename);
$this->sections = array();
@@ -87,8 +87,8 @@ class phpbb_search_sphinx_config
foreach ($config_file as $i => $line)
{
- // if the value of a variable continues to the next line because the line break was escaped
- // then we don't trim leading space but treat it as a part of the value
+ /* If the value of a variable continues to the next line because the line
+ break was escaped then we don't trim leading space but treat it as a part of the value */
if ($in_value)
{
$line = rtrim($line);
@@ -98,11 +98,11 @@ class phpbb_search_sphinx_config
$line = trim($line);
}
- // if we're not inside a section look for one
+ // If we're not inside a section look for one
if (!$section)
{
- // add empty lines and comments as comment objects to the section list
- // that way they're not deleted when reassembling the file from the sections
+ /* add empty lines and comments as comment objects to the section list
+ that way they're not deleted when reassembling the file from the sections*/
if (!$line || $line[0] == '#')
{
$this->sections[] = new phpbb_search_sphinx_config_comment($config_file[$i]);
@@ -110,8 +110,8 @@ class phpbb_search_sphinx_config
}
else
{
- // otherwise we scan the line reading the section name until we find
- // an opening curly bracket or a comment
+ /* otherwise we scan the line reading the section name until we find
+ an opening curly bracket or a comment */
$section_name = '';
$section_name_comment = '';
$found_opening_bracket = false;
@@ -137,28 +137,29 @@ class phpbb_search_sphinx_config
$section_name .= $line[$j];
}
- // and then we create the new section object
+ // And then we create the new section object
$section_name = trim($section_name);
$section = new phpbb_search_sphinx_config_section($section_name, $section_name_comment);
}
}
- else // if we're looking for variables inside a section
+ else
{
+ // If we're looking for variables inside a section
$skip_first = false;
- // if we're not in a value continuing over the line feed
+ // If we're not in a value continuing over the line feed
if (!$in_value)
{
- // then add empty lines and comments as comment objects to the variable list
- // of this section so they're not deleted on reassembly
+ /* then add empty lines and comments as comment objects to the variable list
+ of this section so they're not deleted on reassembly */
if (!$line || $line[0] == '#')
{
$section->add_variable(new phpbb_search_sphinx_config_comment($config_file[$i]));
continue;
}
- // as long as we haven't yet actually found an opening bracket for this section
- // we treat everything as comments so it's not deleted either
+ /* As long as we haven't yet actually found an opening bracket for this section
+ we treat everything as comments so it's not deleted either */
if (!$found_opening_bracket)
{
if ($line[0] == '{')
@@ -175,7 +176,8 @@ class phpbb_search_sphinx_config
}
}
- // if we did not find a comment in this line or still add to the previous line's value ...
+ /* If we did not find a comment in this line or still add to the previous
+ line's value ... */
if ($line || $in_value)
{
if (!$in_value)
@@ -226,21 +228,24 @@ class phpbb_search_sphinx_config
{
$value .= "\n";
$in_value = true;
- continue 2; // go to the next line and keep processing the value in there
+ // Go to the next line and keep processing the value in there
+ continue 2;
}
$value .= $line[$j];
}
}
- // if a name and an equal sign were found then we have append a new variable object to the section
+ /* If a name and an equal sign were found then we have append a
+ new variable object to the section */
if ($name && $found_assignment)
{
$section->add_variable(new phpbb_search_sphinx_config_variable(trim($name), trim($value), ($end_section) ? '' : $comment));
continue;
}
- // if we found a closing curly bracket this section has been completed and we can append it to the section list
- // and continue with looking for the next section
+ /* if we found a closing curly bracket this section has been completed
+ and we can append it to the section list and continue with looking for
+ the next section */
if ($end_section)
{
$section->set_end_comment($comment);
@@ -250,13 +255,14 @@ class phpbb_search_sphinx_config
}
}
- // if we did not find anything meaningful up to here, then just treat it as a comment
+ /* If we did not find anything meaningful up to here, then just treat it
+ as a comment */
$comment = ($skip_first) ? "\t" . substr(ltrim($config_file[$i]), 1) : $config_file[$i];
$section->add_variable(new phpbb_search_sphinx_config_comment($comment));
}
}
- // keep the filename for later use
+ // Keep the filename for later use
$this->loaded = $filename;
}
diff --git a/phpBB/includes/search/sphinx/config_section.php b/phpBB/includes/search/sphinx/config_section.php
index 529254dd5a..ed20dba279 100644
--- a/phpBB/includes/search/sphinx/config_section.php
+++ b/phpBB/includes/search/sphinx/config_section.php
@@ -79,7 +79,7 @@ class phpbb_search_sphinx_config_section
{
for ($i = 0, $size = sizeof($this->variables); $i < $size; $i++)
{
- // make sure this is a variable object and not a comment
+ // Make sure this is a variable object and not a comment
if (($this->variables[$i] instanceof phpbb_search_sphinx_config_variable) && $this->variables[$i]->get_name() == $name)
{
return $this->variables[$i];
@@ -96,7 +96,7 @@ class phpbb_search_sphinx_config_section
{
for ($i = 0, $size = sizeof($this->variables); $i < $size; $i++)
{
- // make sure this is a variable object and not a comment
+ // Make sure this is a variable object and not a comment
if (($this->variables[$i] instanceof phpbb_search_sphinx_config_variable) && $this->variables[$i]->get_name() == $name)
{
array_splice($this->variables, $i, 1);
@@ -127,7 +127,7 @@ class phpbb_search_sphinx_config_section
{
$content = $this->name . ' ' . $this->comment . "\n{\n";
- // make sure we don't get too many newlines after the opening bracket
+ // Make sure we don't get too many newlines after the opening bracket
while (trim($this->variables[0]->to_string()) == '')
{
array_shift($this->variables);