Ticket #431 (closed Bug: fixed)
Forge_Core::__call() arguments - out of bound, uncaught
| Reported by: | xadio | Owned by: | Shadowhand |
|---|---|---|---|
| Priority: | blocker | Milestone: | 2.1.2 |
| Component: | Core | Version: | SVN HEAD |
| Keywords: | Forge_Core out of bound errors uncaught | Cc: |
Description
In the function call() the following code exists
// Create the input
switch(count($args))
{
case 1:
$input = new $input($args[0]);
break;
case 2:
$input = new $input($args[0], $args[1]);
break;
}
The problem is that it assumes all methods will have 1 - 2 arguments. The problem is that < 1 and > 2 arguments are not handled. Unless the conditional test to see if it is an *instanceof* is considered, but even this assumes a instance of a class has been defined. As the error includes a call to the method get_class([Object $object]) which will return because a string is not an object.
Possible fix:
// Create the input
switch(count($args))
{
case 1:
$input = new $input($args[0]);
break;
case 2:
$input = new $input($args[0], $args[1]);
break;
+ default:
+ throw new Kohana_Exception('forge.unknown_input', $input);
}
I think the error thrown should refer to the fact that the input requested had X arguments and it should have had Y arguments, but at least this will give more detail.
Refer to t430 which is in relation to this.
