0
votes

I working with cakephp. In all pages, there is this warning:

Warning (2): strtolower() expects parameter 1 to be string, array given [CORE/src/Controller/Component/AuthComponent.php, line 337]

In line 337:

protected function _isAllowed(Controller $controller)
{
    $action = strtolower($controller->request->params['action']);
    return in_array($action, array_map('strtolower', $this->allowedActions));
}

How to solve this problem?

2
Show us what you get if you replace the strtolower line with var_dump($controller->request->params['action']);exit; Also tell us what you're trying to do. – BeetleJuice
probably $this->allowedActions contain a subarray. Please consider editing your question adding the debug of $this->allowedActions – arilia

2 Answers

0
votes

Please check $this->allowedActions variable is one dimentional array or have sub array also using pr function.

pr($this->allowedActions);
die();

Note that multi dimentional array not work by passing inbuilt php function in with array_map(). You need to make custom function something like custom_strtolower(), and have to pass this function in array_map().

I hope you will debug your self and my trick will be help full you.

0
votes

I understood the reason for the warning and solved it. I used from

$this->Auth->allow(['display','add',['controller'=>'options','action'=>'add']]);  

_isAllowd function checks whether current action is accessible without authentication. This warning is removed ‌by taking this line in AppController .