I'm using Kohana 3.1 and I'm getting a very strange error. The Kohana POST handler seems to think that there's an undefined index when there is not one.
Inside of a controller class:
$post = $this->request->post();
var_dump(isset($post['jid'])); //true
$jid = $post['jid']; //Undefined Index error.
If I actually use $post['jid']
it works fine, but it is annoying 开发者_开发技巧to not be able to assign it to a more convenient variable. Anyone have any idea what would cause this?
ErrorException [ Notice ]: Undefined index: jid
84 $jid = $post['jid'];
var_dump of $post:
array(4) {
["jid"] => string(1) "7"
["topic"] => string(5) "Test1"
["entry"] => string(14) "CHECK ONE TWO"
["enter"] => string(4) "POST"
}
Altough I believe this is a PEBKAC, you can use $this->request->post('jid')
as a getter for that variable.
Maybe you are just skipping the actual POST check?
Sometimes the problem is not as obvious as the error. The page was 302-redirecting (no post) to itself after completing the action where the post check is done. In fact, the initial post went through properly, but be careful about calling a method on $this
when you mean to use another object (at least when $this
is a controller). It's still unclear to me why Kohana didn't crash.
精彩评论