* Admin: fix SQL error when search contains a non-ascii character

This commit is contained in:
Ralf Becker 2015-07-29 10:35:01 +00:00
parent 41127ab765
commit b799107de5
2 changed files with 8 additions and 1 deletions

View File

@ -1249,6 +1249,10 @@ class so_sql
$numeric_columns[] = $col; $numeric_columns[] = $col;
continue; continue;
} }
if ($this->db->Type == 'mysql' && $table_def['fd'][$col_name]['type'] === 'ascii' && !preg_match('/[\x80-\xFF]/', $_pattern))
{
continue; // will only give sql error
}
$columns[] = sprintf($this->db->capabilities[egw_db::CAPABILITY_CAST_AS_VARCHAR],"COALESCE($col,'')"); $columns[] = sprintf($this->db->capabilities[egw_db::CAPABILITY_CAST_AS_VARCHAR],"COALESCE($col,'')");
} }
if($columns) if($columns)

View File

@ -424,7 +424,10 @@ class accounts_sql
if (!isset($GLOBALS['egw_setup']) || in_array(emailadmin_smtp_sql::TABLE, $this->db->table_names(true))) if (!isset($GLOBALS['egw_setup']) || in_array(emailadmin_smtp_sql::TABLE, $this->db->table_names(true)))
{ {
$email_cols = array('coalesce('.$this->contacts_table.'.contact_email,'.emailadmin_smtp_sql::TABLE.'.mail_value) as email'); $email_cols = array('coalesce('.$this->contacts_table.'.contact_email,'.emailadmin_smtp_sql::TABLE.'.mail_value) as email');
if ($this->db->Type == 'mysql' && !preg_match('/[\x80-\xFF]/', $param['query']))
{
$search_cols[] = emailadmin_smtp_sql::TABLE.'.mail_value'; $search_cols[] = emailadmin_smtp_sql::TABLE.'.mail_value';
}
$join .= ' LEFT JOIN '.emailadmin_smtp_sql::TABLE.' ON '.$this->table.'.account_id=-'.emailadmin_smtp_sql::TABLE.'.account_id AND mail_type='.emailadmin_smtp_sql::TYPE_ALIAS; $join .= ' LEFT JOIN '.emailadmin_smtp_sql::TABLE.' ON '.$this->table.'.account_id=-'.emailadmin_smtp_sql::TABLE.'.account_id AND mail_type='.emailadmin_smtp_sql::TYPE_ALIAS;
} }