Role Based Authentication

I use role based authentication in my website. After updating to the newest version of Yii I do get following problem. I did not have this in the older version.

PHP Error

Omschrijving

call_user_func_array() [<a href=‘function.call-user-func-array’>function.call-user-func-array</a>]: First argument is expected to be a valid callback, ‘1’ was given

Bronbestand

C:\Program Files\EasyPHP\www\YiiRoot\framework\base\CComponent.php(592)

    00580:      * @since 1.1.0

00581: */

00582: public function evaluateExpression($expression,$data=array())

00583: {

00584: if(is_string($expression))

00585: {

00586: extract($data);

00587: return @eval(‘return ‘.$expression.’;’);

00588: }

00589: else

00590: {

00591: $data[]=$this;

00592: return call_user_func_array($expression, $data);

00593: }

00594: }

00595: }

00596:

00597:

00598: /**

00599: * CEvent is the base class for all event classes.

00600: *

00601: * It encapsulates the parameters associated with an event.

00602: * The {@link sender} property describes who raises the event.

00603: * And the {@link handled} property indicates if the event is handled.

00604: * If an event handler sets {@link handled} to true, those handlers

Stack Trace

    #0 C:&#092;Program Files&#092;EasyPHP&#092;www&#092;YiiRoot&#092;framework&#092;base&#092;CComponent.php(592): call_user_func_array()

#1 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\auth\CAccessControlFilter.php(301): CAccessRule->evaluateExpression()

#2 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\auth\CAccessControlFilter.php(204): CAccessRule->isExpressionMatched()

#3 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\auth\CAccessControlFilter.php(100): CAccessRule->isUserAllowed()

#4 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\filters\CFilter.php(39): CAccessControlFilter->preFilter()

#5 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\CController.php(983): CAccessControlFilter->filter()

#6 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\filters\CInlineFilter.php(59): FunctiesController->filterAccessControl()

#7 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\filters\CFilterChain.php(126): CInlineFilter->filter()

#8 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\CController.php(283): CFilterChain->run()

#9 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\CController.php(257): FunctiesController->runActionWithFilters()

#10 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\CWebApplication.php(320): FunctiesController->run()

#11 C:\Program Files\EasyPHP\www\YiiRoot\framework\web\CWebApplication.php(120): CWebApplication->runController()

#12 C:\Program Files\EasyPHP\www\YiiRoot\framework\base\CApplication.php(135): CWebApplication->processRequest()

#13 C:\Program Files\EasyPHP\www\WebRoot\vrijwilligers\index.php(11): CWebApplication->run()

me too

my code in controller




	public function accessRules()

	{

		return array(


                        array('allow',  // allow all users to perform 'list' and 'show' actions

				'actions'=>array('admin','update','lovPersonas'),

                                'expression'=>Seguridad::tieneRol('PER_CONSULTA') 

                                ,


			),

			array('allow', // allow authenticated user to perform 'create' and 'update' actions

				'actions'=>array('grabado_ok','delete','create','AutoCompleteLookup'),

				'expression'=>Seguridad::tieneRol('PER_INGRESO'),

			),


			array('deny',  // deny all users

				'users'=>array('*'),

			),

		);

	}




in v1.0.x work fine. why not in 1.1 ?????

put this and work

change

‘expression’=>Seguridad::tieneRol(‘PER_CONSULTA’)

by

‘expression’=>“Seguridad::tieneRol(‘PER_CONSULTA’)==1”




...

   'expression'=>"Seguridad::tieneRol('PER_CONSULTA')==1"

....



why??

thanks

@master (qiang ;) ):

is posible change class CComponent? adding "or is_numeric($expression)"




       public function evaluateExpression($_expression_,$_data_=array())

        {

                if(is_string($_expression_) or is_numeric($_expression_))

                {

                        extract($_data_);

                        return @eval('return '.$_expression_.';');

                }

                else

                {

                        $_data_[]=$this;

                        return call_user_func_array($_expression_, $_data_);

                }

        }



i change

‘expression’=>Seguridad::tieneRol(‘PER_CONSULTA’)

by

‘expression’=>“Seguridad::tieneRol(‘PER_CONSULTA’)”

and work

I only have to change each controller, no problem :(