When the URL has characters like äöå and other non ISO-8859-1 characters, the insert throws an exception.
PDOException: in dblog_watchdog() (line 154 of C:\inetpub\wwwroot\Hevospiste\modules\dblog\dblog.module).
This can be solved by urlencoding the line before entering it to the database.
Working code:
function dblog_watchdog(array $log_entry) {
Database::getConnection('default', 'default')->insert('watchdog')
->fields(array(
'uid' => $log_entry['uid'],
'type' => substr($log_entry['type'], 0, 64),
'message' => $log_entry['message'],
'variables' => serialize($log_entry['variables']),
'severity' => $log_entry['severity'],
'link' => substr($log_entry['link'], 0, 255),
'location' => urlencode($log_entry['request_uri']),
'referer' => $log_entry['referer'],
'hostname' => substr($log_entry['ip'], 0, 128),
'timestamp' => $log_entry['timestamp'],
))
->execute();
}
Comments
Comment #1
acke commentedI noticed this error on IIS when searching with swedish characters. The urlencoding is working and I made a patch for this.
Comment #3
acke commentedPatch against 7.x-dev
Comment #4
acke commented#1: 1922802-1.patch queued for re-testing.
Comment #6
acke commentedNew patch with prefix.
Comment #7
acke commentedChange status.
Comment #8
nickaein commentedI had the same problem on IIS 7.5 with URL Rewriting module and FastCGI. The search worked for english queries but I was getting an Error 500 for Persian search queries.
This patch (#6) fixed the problem. Thanks!
Comment #9
dsclub commented#6: 1922802-6.patch queued for re-testing.
Comment #10
dsclub commentedI got the same problem on IIS 8 with URL Rewrite module and FastCGI.
Search worked well for English queries but got error for Chinese queries.
Patch(#6) got the message “You must include at least one positive keyword with 1 character or more.” And if I input more chars, it will searched nothing!
How can i fix it!!!?
Comment #11
alexpottI wonder if the issue is with the collation being used not supporting utf8 since this should work - might be MSSQL related.
Comment #12
alexpottComment #13
David_Rothstein commentedComment #14
wuinfo - bill wu commentedIs it IIS related or Apache website have the same problem. I am trying to come up with a test. First, need to know how to reproduce it.
Comment #15
acke commentedI have only experienced this on IIS.
Comment #17
daffie commentedRerolled the patch and moved it to the dblog.module.
The patch still needs tests.
Comment #20
dagmarThis was also reported here: #1309720: PDOException problem: seaching strings with special characters
Comment #5 suggests it is a configuration related to IIS:
https://support.microsoft.com/en-us/help/2277918/fix-a-php-application-t...
So this is probably a candidate for
Closed (Works as Designed). Leaving NW from now for more discussion.Comment #21
dagmarFrom the link posted in #20
I added this link to https://www.drupal.org/documentation/install/windows this can be fixed from IIS directly with the hotfix.