Bug Report #2517

ORM throwing ErrorException Undefined index: id

Added by james - almost 5 years ago. Updated about 1 year ago.

Status:ClosedStart date:01/25/2010
Priority:HighDue date:
Assignee:Woody Gilk% Done:

0%

Category:Modules:ORM
Target version:v3.0.5
Resolution:worksforme Points:


Related issues

Related to Kohana v3.x - Bug Report #2231: ORM doesn't wake up properly Closed 10/13/2009

History

#1 Updated by John Heathco almost 5 years ago

Please provide exact instructions on how to produce this bug.

#2 Updated by John Heathco almost 5 years ago

  • Status changed from New to Feedback

#3 Updated by Aleksandr Lazkin almost 5 years ago

james - wrote:

see this forum thread: http://forum.kohanaphp.com/comments.php?DiscussionID=4606

here is exact case on how i produce this bug
http://forum.kohanaphp.com/comments.php?DiscussionID=4622. First comes DB error and then after refresh comes undefined index: id error. In my case, this DB error is started from line $this->session = Session::instance(); in controller before() method.

#4 Updated by John Heathco over 4 years ago

  • Assignee changed from John Heathco to Woody Gilk

I believe this is because (as Woody stated in that topic) connection details are removed from the database. Woody, what are your thoughts on this? I'm still unsure how to reproduce this (I've serialized an ORM model followed by an unserialization and dump without issue).

#5 Updated by Woody Gilk over 4 years ago

  • Status changed from Feedback to Closed
  • Target version set to v3.0.5
  • Resolution set to worksforme

I have absolutely no idea when you would have a situation where unserializing would cause the database re-connection to fail.

As such, I am going to close this issue as we cannot replicate it. If new information can be provided, please reopen the issue.

#6 Updated by Jason Blair over 4 years ago

I've been digging through Kohana investigating what I think might be the same problem and it seems that it is caused by PHP errors which bypass the Kohana error handler, and when the PHP error handler shuts down it doesn't serialize Session data properly.

For example, it seems you can trigger this by using the default Auth module and logging in, then causing a fatal error that bypasses the Kohana::exception_handler ("$undefined_variable->method();" works for me, but not just an undefined variable by itself or a undefined method on a defined variable - object or otherwise).

It seems like it isn't serialized properly after the PHP error and when you reload, it tries to __wakeup and the Auth_User->_db member looks like this:

    [_db:protected] => Database_MySQL Object
        (
            [_identifier:protected] => `
            [last_query] => // SQL
            [_instance:protected] => default
            [_connection:protected] => 0
            [_config:protected] => Array
                (
                    [type] => mysql
                    [table_prefix] => 
                    [charset] => utf8
                    [caching] => 
                    [profiling] => 1
                )

        )

So you get an exception: Undefined index 'connection' in the MySQL Database object (after it was unset in the previous request) when it tries to reconnect (since the _connection is "0")

After you refresh again you start getting the "Undefined index 'id'" exceptions when the ORM object in _SESSION couldn't reload the _object array, and so it is empty from then on out.

#7 Updated by Anonymous over 2 years ago

I eat spam for breakfast.

#8 Updated by farijon farijon over 2 years ago

I love spam.

#9 Updated by vishnu sant about 1 year ago

The error showing in ORM module is seen in common to many kohana frame work users. I think it’s a temporary bug and it will be fixed in the next update of the frame work. According to my opinion you need to wait until the next update is released.
http://www.omnitechsupport.com/blog

Also available in: Atom PDF