Thanks to one of my partners analysis of the segfault, I narrowed it down to a number of things. There are a number of problems in the search.class.inc.php file.
For starters, the following function was causing the initial segfaults:
/**
* validListIDs : check the validity of a value separated list of Ids
*/
function validListIDs($IDs){
if (preg_match('/^([0-9]+,)*[0-9]+$/',$IDs) == 0) return false;
return true;
}
If I commented out the preg_match line then the error goes away. However, I started having some SQL errors after that. Further investigation revealed that the following function was to blame:
// document group allowed regarding user authentification
if ($this->validListIDs($this->cfg['docgrp'])) {
$this->main['jfilters'][] = array(
'tb_name' => $this->getShortTableName('document_groups'),
'tb_alias' => 'dg',
'main' => 'id',
'join' => 'document',
'field' => 'document_group',
'oper' => 'in',
'value' => $this->cfg['docgrp'],
'or' => array(
'field' => 'privateweb',
'oper' => '=',
'value' => '0'
)
);
}
else {
// documents should be public
$this->main['filters'][] = array(
'field' => 'privateweb',
'oper' => '=',
'value' => '0'
);
}
break;
Seems that the ’docgrp’ was blank and was still being passed into the SQL query, thus causing an error. So I modified it a bit to check for an empty variable:
// document group allowed regarding user authentification
if(!empty($this->cfg['docgrp'])){
if ($this->validListIDs($this->cfg['docgrp'])) {
$this->main['jfilters'][] = array(
'tb_name' => $this->getShortTableName('document_groups'),
'tb_alias' => 'dg',
'main' => 'id',
'join' => 'document',
'field' => 'document_group',
'oper' => 'in',
'value' => $this->cfg['docgrp'],
'or' => array(
'field' => 'privateweb',
'oper' => '=',
'value' => '0'
)
);
} else {
// documents should be public
$this->main['filters'][] = array(
'field' => 'privateweb',
'oper' => '=',
'value' => '0'
);
}
} else {
// documents should be public
$this->main['filters'][] = array(
'field' => 'privateweb',
'oper' => '=',
'value' => '0'
);
}
break;
I’m making changes in short order so I would presume that there is a better way to handle this. Just trying to stop the errors is all and keep it working.
After that, I started noticing that returns on search results came up painfully slow. Error logs revealed a timeout on lines like these:
$wordLeft = $mbStrpos($mbStrtolower($text), $mbStrtolower($searchTerm));
Don’t know why variables are being used in place of the actual function names. I changed the two instances of these to this:
$wordLeft = strpos(strtolower($text), strtolower($searchTerm));
That seems to speed things up quite a bit. I’m sure there are a number of other things but these are the changes I made that made the errors go away. Will compare with an earlier version though and see if that reveals anything.