[Solar-talk] Is it just me or is Paul going to kill me? If second value is 0 controller doesn't find it

Paul M Jones pmjones at paul-m-jones.com
Fri May 2 14:53:21 CDT 2008


On May 2, 2008, at 12:42 , Kilbride, James P. wrote:
> if it's 0 though I get this:
>
> Warning: Missing argument 2 for  
> ProcedureMatrix_App_Matrix::actionUpdate() in C:\Solar 
> \ProcedureMatrix\App\Matrix.php on line 73
>

First, you'll want to provide default values for all your action  
method params, just on principle.  Defaulting that second one to  
"zero" or null will help here.

Having said that, it should not be dropping explicit zeroes like  
that.  I know exactly what the bug is; Antti and I ran into something  
similar on parsing URIs, iirc.   In Solar_Controller_Page::_load(), at  
the very end, you will see this:

         // finally, remove blank info elements from the end.
         // this happens sometimes with elements being added
         // and removed from format checking, and helps make
         // sure that action default parameters are honored.
         $i = count($this->_info);
         while ($i --) {
             if (! empty($this->_info[$i])) {
                 // not empty, stop removing blanks
                 break;
             } else {
                 unset($this->_info[$i]);
             }
         }


My bet is that if you change the `! empty($this->_info[$i])` to  
`trim($this->_info[$i]) != ''` then it'll work as expected.  (PHP's  
dynamic variable casting is usually a boon, but in cases like this  
it's a bane.  A string zero looks like an int zero, and that means  
empty() is true.)

Let me know if that change works for you, and I'll apply it.

-- pmj


p.s. "Am I going to kill you?"  Of course not -- you know me better  
than that.  ;-)




More information about the Solar-talk mailing list