Project

General

Profile

Actions

Defect #4766

open

Bad PDF files and SQL queries generated under certain locales

Added by Josef Grahn about 14 years ago. Updated about 13 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
PDF export
Target version:
-
Start date:
2010-02-08
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

When running the latest stable version (0.9.2 from branches/0.9-stable) of Redmine with a Swedish locale (and likely others), PDF export as well as some SQL queries appear to stop working after the system has been in use for a while (typically a few hours).

Immediately after the server has been restarted, everything works fine. However, after certain, yet to be determined functions have been used in the web interface (but seemingly at least after having added a "New issue"), exported PDF files and some SQL queries start to become corrupt. This appears to have to do with floating point numbers being encoded as "123,45" rather than "123.45".

My best guess is that some code path inadvertently changes the locale used by sprintf(), which results in comma being used as decimal separator character instead of point. Consequently, SQL statements containing floating point values, as well as PDF files generated by the system, suddenly get invalid syntax (or valid but with a different meaning).

Exact version of Redmine:

URL: svn://rubyforge.org/var/svn/redmine/branches/0.9-stable
Archive UUID: e93f8b46-1217-0410-a6f0-8f06a7374b81
Revision: 3394

Output from script/about:

About your application's environment
Ruby version 1.8.6 (x86_64-linux)
RubyGems version 1.3.5
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root /opt/redmine/redmine-0.9
Environment production
Database adapter mysql
Database schema version 20091227112908

System locale:

LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_PAPER="sv_SE.UTF-8"
LC_NAME="sv_SE.UTF-8"
LC_ADDRESS="sv_SE.UTF-8"
LC_TELEPHONE="sv_SE.UTF-8"
LC_MEASUREMENT="sv_SE.UTF-8"
LC_IDENTIFICATION="sv_SE.UTF-8"
LC_ALL=

Actions #1

Updated by Jean-Philippe Lang about 14 years ago

some SQL queries start to become corrupt

Can you attach a log that show one of these corrupted queries?

Actions #2

Updated by Josef Grahn about 14 years ago

Certainly. Terminal output from the server is as follows (notice how the value "16" has become "16,0", which is being interpreted by MySQL as two distinct arguments instead of one):

Processing IssuesController#edit (for 192.168.16.162 at 2010-02-08 20:29:48) [POST]
  Parameters: {"time_entry"=>{"comments"=>"", "activity_id"=>"", "hours"=>""}, "commit"=>"Spara", "action"=>"edit", "authenticity_token"=>"ZSdpLVFUK6Z0pW5woGHauU6sdZFjnTyu/9CO0OIYduY=", "id"=>"17", "notes"=>"", "controller"=>"issues", "issue"=>{"start_date"=>"2010-02-08", "estimated_hours"=>"16", "lock_version"=>"0", "priority_id"=>"4", "subject"=>"XXXXX", "description"=>"XXXXX", "tracker_id"=>"5", "done_ratio"=>"0", "due_date"=>"", "assigned_to_id"=>"4", "status_id"=>"1", "custom_field_values"=>{"2"=>"XXXXX", "3"=>"1"}}, "attachments"=>{"1"=>{"description"=>""}}}

ActiveRecord::StatementInvalid (Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0, `lock_version` = 1, `updated_on` = '2010-02-08 20:29:48'

              WHERE ' at line 2:               UPDATE `issues`
              SET `estimated_hours` = 16,0, `lock_version` = 1, `updated_on` = '2010-02-08 20:29:48'
              WHERE id = 17
              AND `lock_version` = 0
):
  app/controllers/issues_controller.rb:196:in `edit'
  /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
  /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
  /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
  /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering /opt/redmine/redmine-0.9/public/500.html (500 Internal Server Error)

The equivalent when exporting to PDF can be seen here:

%PDF-1.3
3 0 obj
<</Type /Page
/Parent 1 0 R
/MediaBox [0 0 841,89 595,28]
/Resources 2 0 R
/Contents 4 0 R>>
endobj

...

Notice how it says "/MediaBox [0 0 841,89 595,28]" instead of "/MediaBox [0 0 841.89 595.28]".

Actions #3

Updated by Jean-Philippe Lang about 14 years ago

Thanks. It looks strange and I'm not able to reproduce this problem.
Did you install any plugin or make any change to the core?

Actions #4

Updated by Josef Grahn about 14 years ago

No, I don't recall installing any plugins or making any other changes.

I tried installing the same version of Redmine on a development system, with the same locale. Interestingly, the problem does not seem to appear on that system. Evidently, there is something particular with the system setup involved here, necessary for the problem to occur.

I'd be willing to help track this issue down, as best I can. I have a fair amount of programming experience, but I'm new to Ruby, so I'm unsure how to best proceed. Presumably, I could add checks using sprintf() at various places in the code, to try to pin down the exact place where the formatting behavior changes.

Actions #5

Updated by Toshi MARUYAMA about 13 years ago

  • Category set to PDF export
  • Priority changed from High to Normal
Actions

Also available in: Atom PDF