Php YII:访问规则不';不能使用Chrome,但可以使用Firefox
我使用最新版本的YII v1.1.14: 我使用以下代码创建控制器:Php YII:访问规则不';不能使用Chrome,但可以使用Firefox,php,google-chrome,firefox,yii,Php,Google Chrome,Firefox,Yii,我使用最新版本的YII v1.1.14: 我使用以下代码创建控制器: class MyController extends CController { public $layout='//layouts/column1'; public $menu=array(); public $breadcrumbs=array(); public $resourceUrl = ''; public $pageTitle = '' ; public $
class MyController extends CController
{
public $layout='//layouts/column1';
public $menu=array();
public $breadcrumbs=array();
public $resourceUrl = '';
public $pageTitle = '' ;
public $pageSubTitle = '';
public $baseUrl = '' ;
public $themeUrl ='';
public $additionalJS = '' ;
public $currentMenu = '' ; // for menu highlighting (use small case)
public function init(){
$this->themeUrl = YII::app()->theme->baseUrl;
$this->resourceUrl = YII::app()->theme->baseUrl.'/resources/';
$this->pageTitle = strtoupper(Yii::app()->controller->id) ;
$this->baseUrl = YII::app()->baseUrl;
$this->currentMenu = 'home';
}
public function isCurrentMenu($topic){
if($this->currentMenu == $topic)
return 'current-menu-item';
}
}
class DashboardController extends MyController
{
public $active = 'dashboard';
public $pageTitle = 'Dashboard';
public $pageSubTitle = 'manage your inventory and all stuff';
public $layout = '//layouts/dashboard';
public function filters()
{
return array( 'accessControl' ); // perform access control for CRUD operations
}
public function accessRules()
{
return array(
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('index','createStuff'),
'roles'=>array('user'),
//'expression'=>'Yii::app()->user->roles== "admin"',
//'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('delete'),
'roles'=>array('admin'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('indxex'),
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
public function actionCreateStuff()
{
$this->render('createStuff');
}
public function actionIndex()
{
//echo Yii::app()->user->checkAccess('user');exit;
$this->render('index',array());
}
....
}
在main.php中
'user'=>array(
// enable cookie-based authentication
'class'=>'WebUser',
'allowAutoLogin'=>true,
'loginUrl'=>array('site/login'),
'returnUrl'=>array('dashboard/index'),
),
当我尝试使用谷歌浏览器访问该页面时,访问规则不起作用,它只允许所有人访问该页面。。。但在Mozilla Firefox上,它做了正确的事情,先登录页面
如何在chrome上调试这个bug
错误页:(为了更好地查看)
PHP注意事项
正在尝试获取非对象的属性
D:\xampp\htdocs\buntelangame\themes\initializer\views\layouts\dashboard.php(75)
63
65
66
67
68
69
70
71-
72
78
79-
80
八十二
83-
84
堆栈跟踪
#0
+D:\yii\bin\framework\web\CBaseController.php(126):需要(“D:\xampp\htdocs\buntelangame\themes\initializer\views\layouts\das…”)
#1
+D:\yii\bin\framework\web\CBaseController.php(95):CBaseController->renderInternal(“D:\xampp\htdocs\buntelangame\themes\initializer\views//layouts/da…”,
数组(“内容”=>“仪表板/索引此页面将
包含,st…“”,true)
#2+D:\yii\bin\framework\web\CController.php(784):CBaseController->renderFile(“D:\xampp\htdocs\buntelangame\themes\initializer\views//layouts/da…”, 数组(“内容”=>“仪表板/索引此页面将 包含,st…“”,true) #3
–D:\xampp\htdocs\buntelangame\protected\controllers\DashboardController.php(46): CController->render(“索引”,数组()) 41 } 42 43公共职能行动指数() 44 { 45//echo Yii::app()->user->checkAccess('user');退出; 46$this->render('index',array()); 47 } 48 49公共功能actionListStuff() 50 { 51$this->render('listStuff'); #4
+D:\yii\bin\framework\web\actions\CInlineAction.php(49):DashboardController->actionIndex() #5
+D:\yii\bin\framework\web\CController.php(308):CInlineAction->runWithParams(数组(“/dashboard/index”=>”) #6
+D:\yii\bin\framework\web\filters\CFilterChain.php(133):CController->runAction(CInlineAction) #7
+D:\yii\bin\framework\web\filters\CFilter.php(40):CFilterChain->run() #8
+D:\yii\bin\framework\web\CController.php(1145):CFilter->filter(CFilterChain) #9
+D:\yii\bin\framework\web\filters\CInlineFilter.php(58):CController->filterAccessControl(CFilterChain) #10
+D:\yii\bin\framework\web\filters\CFilterChain.php(130):CInlineFilter->filter(CFilterChain) #11
+D:\yii\bin\framework\web\CController.php(291):CFilterChain->run() #12
+D:\yii\bin\framework\web\CController.php(265):CController->runActionWithFilters(CInlineAction, 数组(“访问控制”)) #13
+D:\yii\bin\framework\web\CWebApplication.php(282):CController->run(“索引”) #14
+D:\yii\bin\framework\web\CWebApplication.php(141):CWebApplication->runController(“仪表板/索引”) #15
+D:\yii\bin\framework\base\capapplication.php(180):CWebApplication->processRequest() #16
–D:\xampp\htdocs\buntelangame\index.php(13):capapplication->run() 08已定义('yi_DEBUG')或定义('yi_DEBUG',true); 09//指定每个日志消息中应显示多少级别的调用堆栈 10已定义(“YII_跟踪水平”)或定义(“YII_跟踪水平”,3); 11 一次12美元(yii); 13 Yii::createWebApplication($config)->run(); 2014-07-11 18:43:39 Apache/2.4.9(Win32)OpenSSL/1.0.1g PHP/5.5.11 Yii Framework/1.1.14 编辑: 它在icognito模式下工作。
我的google chrome版本:35.0.1916.153 m版Real quick:最新版本为1.1.15。这不会影响您的问题,但会解决一个主要的安全问题。是否清除缓存?尝试升级到1.115(最新版本)…在chrome上仍然不起作用。清除缓存也没有帮助…仍然会产生相同的问题。错误:
尝试获取非对象的属性
是问题所在,通常意味着您正在引用$someArray->asAnObject
。此外,您的代码不应该在两种浏览器中都起作用。我会尝试在中清除两种浏览器都可以,甚至可以尝试匿名模式。希望这能为您指明正确的方向
PHP notice
Trying to get property of non-object
D:\xampp\htdocs\buntelangame\themes\initializr\views\layouts\dashboard.php(75)
63 <a href="javascript:;" class="menu-toggler responsive-toggler" data-toggle="collapse" data-target=".navbar-collapse">
64 </a>
65 <!-- END RESPONSIVE MENU TOGGLER -->
66 <!-- BEGIN TOP NAVIGATION MENU -->
67 <div class="top-menu">
68 <ul class="nav navbar-nav pull-right">
69
70 <!-- BEGIN USER LOGIN DROPDOWN -->
71 <li class="dropdown dropdown-user">
72 <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
73 <img alt="" class="img-circle" src="<?php echo $this->themeUrl; ?>/assets/admin/layout/img/avatar3_small.jpg"/>
74 <span class="username">
75 <?php echo Yii::app()->session['user']->nama_lengkap;?> </span>
76 <i class="fa fa-angle-down"></i>
77 </a>
78 <ul class="dropdown-menu">
79 <li>
80 <a href="extra_profile.html">
81 <i class="icon-user"></i> My Profile </a>
82 </li>
83 <li>
84 <a href="inbox.html">
85 <i class="icon-envelope-open"></i> My Inbox <span class="badge badge-danger">
86 3 </span>
87 </a>
Stack Trace
#0
+ D:\yii\bin\framework\web\CBaseController.php(126): require("D:\xampp\htdocs\buntelangame\themes\initializr\views\layouts\das...")
#1
+ D:\yii\bin\framework\web\CBaseController.php(95): CBaseController->renderInternal("D:\xampp\htdocs\buntelangame\themes\initializr\views//layouts/da...",