From: Ken Brush Date: 2005-08-16T01:25:47+09:00 Subject: Bug in cgi/session Hi All, I couldn't find a bug tracker for ruby, to see if this was known or not. Anyhow, there is a problem with cgi/session. It'll convert a value of a hash stored in the session to an array, I think on close. Here's the test case I'm using: --- Start ruby code --- #!/usr/bin/ruby # Test case for cgi session require 'cgi' require 'cgi/session' cgi = CGI.new("html4") begin session = CGI::Session.new(cgi, 'new_session' => false) rescue ArgumentError session = CGI::Session.new(cgi, 'new_session' => true) end session['cart'] ||= Hash.new(0); session['cart'][cgi.params["id"]] += 1 out = "#{cgi.params["id"]} -- #{session['cart'][cgi.params["id"]]}" print cgi.header print cgi.out() { out } session.close -- End of ruby code --- When accessed with something like: http://localhost/~kbrush/add.rb?id=foo it'll print 'foo -- 1' then access it again and you'll get an 'Internal Error' This is the error in error.log: [Mon Aug 15 09:25:27 2005] [error] mod_ruby: error in ruby [Mon Aug 15 09:25:27 2005] [error] mod_ruby: /home/kbrush/public_html/add.rb:19:in `[]': cannot convert Array into Integer (TypeError) [Mon Aug 15 09:25:27 2005] [error] mod_ruby: from /home/kbrush/public_html/add.rb:19 [Mon Aug 15 09:25:27 2005] [error] mod_ruby: from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load' [Mon Aug 15 09:25:27 2005] [error] mod_ruby: from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler' [Mon Aug 15 09:25:28 2005] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico you get the same error if you use mod_ruby or not. -Ken