Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => PostgreSQL and SQLite Support => Topic started by: draconins on March 05, 2014, 07:05:00 PM

Title: Search fails to find keyword in unless " Search in topic subjects only" checked
Post by: draconins on March 05, 2014, 07:05:00 PM
Hi All,

I got an issue for search, which is for some reason it can not find a word which only appears in the subject of the post.
If I enable " Search in topic subjects only", the post can be found, but not when the " Search in topic subjects only" unchecked.

I suspect it is a search database part and I have manually patched http://www.simplemachines.org/community/index.php?topic=470906.0 into DbPackages-PostgreSQL and enable large index database as I got case insensitive search problem.

This is for PostGres 9.2 + SMF 2.0.7
Title: Re: Search fails to find keyword in unless " Search in topic subjects only" checked
Post by: draconins on March 07, 2014, 06:35:54 PM
Patching here and there , mainly https://github.com/SimpleMachines/SMF2.1/pull/785 improves the situation.
But still comes to error

2: preg_replace(): No ending delimiter '~' found
Apply Filter: Only show the errors from this file
File: C:/PHPWeb/Root/forum/Sources/DbSearch-postgresql.php

Any idea where it comes from? I have checked old post at http://www.simplemachines.org/community/index.php?topic=350920.0
but from what i can see, this is fixed already in 2.0.7

Title: Re: Search fails to find keyword in unless " Search in topic subjects only" checked
Post by: Oldiesmann on March 12, 2014, 11:52:21 AM
What line is that error being generated on, and what code is on that line? Without that info it's tough to figure out what's going on.
Title: Re: Search fails to find keyword in unless " Search in topic subjects only" checked
Post by: draconins on April 10, 2014, 06:52:19 PM
Line 93

It is when    

if (isset($replacements[$identifier]))
==>93:    $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
94:    elseif (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
95:    {
96:    $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
97:    // Don't error on multi-insert.
98:    $db_values['db_error_skip'] = true;
99:    }
100:    
101:    $return = $smcFunc['db_query']('', $db_string,
102:    $db_values, $connection
103:    );
104:    
105:    return $return;
106:    }
Title: Re: Search fails to find keyword in unless " Search in topic subjects only" checked
Post by: draconins on April 10, 2014, 08:16:05 PM
looking on variable replacement

It seems on the following part:
'create_tmp_log_search_messages' => array(
         '~mediumint\(\d\)' => 'int',
         '~unsigned~i' => '',
         '~ENGINE=MEMORY~i' => '',
      ),

It is missing "~i" on the trailing
Title: Re: Search fails to find keyword in unless " Search in topic subjects only" checked
Post by: draconins on April 11, 2014, 09:39:17 AM
Seems fixing the above part solves the problem. The location is on line 68 on same file.
Title: Re: Search fails to find keyword in unless " Search in topic subjects only" checked
Post by: emanuele on April 25, 2014, 03:24:18 AM
Oh I forgot to say thanks for the debugging and the fix...

Thanks! ;D