Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Bug with session class?
  • Hi guys, I'm getting the following error:
    Fuel\Core\Database_Exception [ 1054 ]: Unknown column 'ip_address' in 'field list' [ INSERT INTO `sessions` (`session_id`, `previous_id`, `ip_address`, `user_agent`, `created`, `updated`, `payload`, `ip_hash`) VALUES ('6727f2a533e8f3be0bb8a83b764e661b', '6727f2a533e8f3be0bb8a83b764e661b', '::1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:5.0.1) Gecko/20100101 Firefox/5.0.1', 1311819045, 1311819045, '', '1ba0d4508441bcdb896203d32d573632') ]
    

    I'm on the latest commit of the develop branch for core. Any ideas?
  • Hey,
    look up here:
    http://fuelphp.com/dev-docs/classes/session/config.html it should be ip_hash (char32), for supporting ipv4, ipv6 addresses etc. Good luck
  • Oddly enough this issue has seemingly resolved itself. I wonder if it was some weird cache thing with MySQL or something... though I did cycle both Apache and MySQL...
  • Database layout has been changed from ip_address to ip_hash in RC3.
  • Harro Verton wrote on Thursday 28th of July 2011:
    Database layout has been changed from ip_address to ip_hash in RC3.

    Yeah, and my error is that the `ip_address` field doesn't exist.... see the problem? The ip_address field shouldn't exist.
  • There is only one DB::insert() in the sessions' db driver, which is in the create() method. It uses the $this->keys array to define both the field names and the values for the insert statement. If you have 'ip_address' there, you're using old code.
  • Harro Verton wrote on Friday 29th of July 2011:
    There is only one DB::insert() in the sessions' db driver, which is in the create() method. It uses the $this->keys array to define both the field names and the values for the insert statement. If you have 'ip_address' there, you're using old code.

    Nope, I'm not using old code, but the (Retarded) forum software cut off the most important parts of my error. I've pasted it below outside of code tags so you can have a better picture of what's going on. I'd like to mention that I checked with git status, on latest commit with no modified files. I did a 'grep' search for 'ip_address' in my project. No results. I did a search inside of eclipse for 'ip_address', again, with no results. Here's the error. You'll notice it's trying to write to both the ip_hash and ip_address fields... Fuel\Core\Database_Exception [ 1054 ]: Unknown column 'ip_address' in 'field list' [ INSERT INTO `sessions` (`session_id`, `previous_id`, `ip_address`, `user_agent`, `created`, `updated`, `payload`, `ip_hash`) VALUES ('6727f2a533e8f3be0bb8a83b764e661b', '6727f2a533e8f3be0bb8a83b764e661b', '::1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:5.0.1) Gecko/20100101 Firefox/5.0.1', 1311819045, 1311819045, '', '1ba0d4508441bcdb896203d32d573632') ] I am tearing my hair out here over this. I don't understand it at all. As you can see, it's trying to write to ip_hash (like it should be) and yet still trying to write to ip_address....
  • Ok, different than I thought. The keys array is part of the session cookie. So if you have a valid cookie from pre-RC3 code, then that will still contain the 'ip_address' field. As I wrote before, the keys of this array are assumed to be fields in the session table, so that's were it comes from. Delete the session cookie manually to fix this.
  • Harro Verton wrote on Friday 29th of July 2011:
    Ok, different than I thought. The keys array is part of the session cookie. So if you have a valid cookie from pre-RC3 code, then that will still contain the 'ip_address' field. As I wrote before, the keys of this array are assumed to be fields in the session table, so that's were it comes from. Delete the session cookie manually to fix this.

    Aha! This is actually what I was thinking had caused the issue, since it did clear itself up several hours later. It isn't likely to affect many people, but there should be something that can be done to force the removal of the 'ip_address' from the old cookie before trying to write to the database.
  • It's always possible to add extra checks, but that will add additional execution time, which isn't needed for the vast majority of the the users. For the future, we'll have to think about how we're going to communicate the impact of stuctural changes like this.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion