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(); 
}
CommentFileSizeAuthor
#17 1922802-17.patch704 bytesdaffie
#6 1922802-6.patch637 bytesacke
#1 1922802-1.patch629 bytesacke

Comments

acke’s picture

Status: Active » Needs review
StatusFileSize
new629 bytes

I noticed this error on IIS when searching with swedish characters. The urlencoding is working and I made a patch for this.

Status: Needs review » Needs work

The last submitted patch, 1922802-1.patch, failed testing.

acke’s picture

Version: 7.19 » 7.x-dev

Patch against 7.x-dev

acke’s picture

Status: Needs work » Needs review

#1: 1922802-1.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1922802-1.patch, failed testing.

acke’s picture

StatusFileSize
new637 bytes

New patch with prefix.

acke’s picture

Status: Needs work » Needs review

Change status.

nickaein’s picture

I 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!

dsclub’s picture

#6: 1922802-6.patch queued for re-testing.

dsclub’s picture

I 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!!!?

alexpott’s picture

Version: 7.x-dev » 8.0.x-dev
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs tests, +mssql

I wonder if the issue is with the collation being used not supporting utf8 since this should work - might be MSSQL related.

alexpott’s picture

David_Rothstein’s picture

Issue tags: +Needs backport to D7
wuinfo - bill wu’s picture

Is 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.

acke’s picture

I have only experienced this on IIS.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

daffie’s picture

Component: database system » dblog.module
StatusFileSize
new704 bytes

Rerolled the patch and moved it to the dblog.module.

The patch still needs tests.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dagmar’s picture

This 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.

dagmar’s picture

Status: Needs work » Closed (works as designed)

From the link posted in #20

This problem occurs because the FastCGI module in IIS 7.5 uses ASCII encoding when you set server variables. Therefore, the REQUEST_URI server variable is not set correctly when the URL contains UTF-8 characters.

I added this link to https://www.drupal.org/documentation/install/windows this can be fixed from IIS directly with the hotfix.