Fatal error: Call to a member function isAllowed() on a non-object

Hi everyone,

When I first time run website it is always show me this error, after refresh it is works normal. This kind of issue not depend of running system. The same with *nix or windows.

Fatal error: Call to a member function isAllowed() on a non-object in D:\WebServer\domains\745221\public_html\app\plugins\Security.php on line 89

Fragment of code has taken from sample invo-master (http://snag.gy/lc656.jpg)

Any idea? What problem is?



82.8k

Can you download the latest code for the security plugin? I think a bug fix was added in the recent days

https://github.com/phalcon/invo/blob/master/app/plugins/Security.php



2.0k

There is also something strange with validation. Situation next: 1. I created form similar to Products edit form (D:\WebServer\domains\745221\publichtml\app\views\products\edit.phtml) 2. After I fill the form and if entered value not get validation, application show me error (Value of field 'ident' doesn't match regular expression) - it is a true. But the same time it show me "Warning: Missing argument 1 for AccountsController::editAction() in D:\WebServer\domains\745221\publichtml\app\controllers\AccountsController.php on line 112" - function editAction the same as in Products. 3. If i click to Save button one more time (without any changes), application take me out and show error Account does not exist 74522119 (i have account 745221, but what does 19 mean, because i am not editing record id 19, i am just editing record with id 5).

If my explanation not clear i can sent screenshots.



82.8k

Could you please post the full code in a Gist (https://gist.github.com/)?



2.0k

Scenario like this: 1. I fill the form 2. Application check value according my validation rule 3. Code find that my value is wrong if (!$accounts->save()) { foreach ($accounts->getMessages() as $message) { $this->flash->error((string) $message); }

        return $this->forward("accounts/edit/".$accounts->id); // let id equal 1

} 3'. forward me to accounts/edit/1 links 4. But when we look at address bar we can see that url not accounts/edit/, but /accounts/save 5. This mean that this code public function editAction($id) { ... } Couldn't get $id from URL and edit.phtml recieve error message as value of id input <input type="hidden" name="id" id="id" value="<br /> <b>Notice</b>: Undefined variable: id in <b>D:\WebServer\domains\745221\public_html\app\views\accounts\edit.phtml</b> on line <b>19</b><br /> " />

Something wrong in code, but not in framework as i see.



2.0k

My code the same as sample INVO-master.



82.8k

I think $this->forward is not completely implemented in INVO, it was just a helper to write forwards in an easier way, check how it is implemented:

https://github.com/phalcon/invo/blob/master/app/controllers/ControllerBase.php#L13

It's only taking into account, controller/action, doing a direct forward will fix this problem:

return $this->dispatcher->forward(array(
     'controller' => 'accounts',
     'action' => 'edit',  
     'params' => array($accounts->id)
));

Or fix the forward helper to have this behavior



2.0k

I also try do like this but result the same.

<input type="hidden" name="id" id="id" value="<br /> <b>Notice</b>: Undefined variable: id in <b>D:\WebServer\domains\745221\public_html\app\views\accounts\edit.phtml</b> on line <b>19</b><br /> " />



82.8k

Did you fixed the forward?



2.0k

I don't know why, but i see that editAction function couldn't get parameters (if) from
return $this->dispatcher->forward(array( 'controller' => 'accounts', 'action' => 'edit',
'params' => array($accounts->id) ));



2.0k

Yes i fixed it with bit change: return $this->dispatcher->forward(array( 'controller' => 'accounts', 'action' => 'edit', 'params' => array("id" => $accounts->id, ...) // for every variable ));

Is there way send all variables by params, or i must right every variable separate as i did with 'id'?