Yii Framework Forum: Chapter 6 pg 117 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 6 pg 117

#1 User is offline   nolte 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 27-October 11

Posted 27 October 2011 - 12:08 PM

Hey Im following the book and on the part that we define that you cant create an Issue without having a project linked to it, Im having the following problem, apparently the call to filterchain is failing, where is it defined or how can I fix this?

Undefined variable: filterchain
/Users/user/Sites/yii11/trackstar/protected/controllers/IssueController.php(217)

205      public function filterProjectContext($filterChain)
206      {
207         //set the project identifier based on either the GET or POST input
208         //request variables, since we allow both types for our actions
209          $projectId = null;
210          if(isset($_GET['pid']))
211               $projectId = $_GET['pid'];
212          else
213               if(isset($_POST['pid']))
214                $projectId = $_POST['pid'];
215        $this->loadProject($projectId);
216          //complete the running of other filters and execute the requested action
217          $filterchain->run();
218      }
219 }




Stack Trace
#0 +
/Users/user/Sites/yii11/framework/web/filters/CInlineFilter.php(59): IssueController->filterProjectContext(CFilterChain)
#1 +
/Users/user/Sites/yii11/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain)
#2 +
/Users/user/Sites/yii11/framework/web/filters/CFilter.php(41): CFilterChain->run()
#3 +
/Users/user/Sites/yii11/framework/web/CController.php(1144): CFilter->filter(CFilterChain)
#4 +
/Users/user/Sites/yii11/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)
#5 +
/Users/user/Sites/yii11/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain)
#6 +
/Users/user/Sites/yii11/framework/web/CController.php(283): CFilterChain->run()
#7 +
/Users/user/Sites/yii11/framework/web/CController.php(257): CController->runActionWithFilters(CInlineAction, array("accessControl", "projectContext + create"))
#8 +
/Users/user/Sites/yii11/framework/web/CWebApplication.php(277): CController->run("create")
#9 +
/Users/user/Sites/yii11/framework/web/CWebApplication.php(136): CWebApplication->runController("issue/create")
#10 +
/Users/user/Sites/yii11/framework/base/CApplication.php(158): CWebApplication->processRequest()
#11 –
/Users/user/Sites/yii11/trackstar/index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true); 09 // specify how many levels of call stack should be shown in each log message 10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3); 11 12 require_once($yii); 13 Yii::createWebApplication($config)->run();
0

#2 User is offline   bumslayer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 19-October 11
  • Location:Wherever I may roam.

Posted 27 October 2011 - 12:44 PM

Edit line 217 above so it says $filterChain->run(); instead (PHP is a case-sensitive language, and you are actually referring to 2 variables above (filterchain and filterChain), one of which is undefined and used resulting to your error. :)
0

#3 User is offline   nolte 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 27-October 11

Posted 28 October 2011 - 10:11 AM

View Postbumslayer, on 27 October 2011 - 12:44 PM, said:

Edit line 217 above so it says $filterChain->run(); instead (PHP is a case-sensitive language, and you are actually referring to 2 variables above (filterchain and filterChain), one of which is undefined and used resulting to your error. :)


Awesome, I wasn't aware of that tiny error. Thanks a lot!
0

#4 User is offline   A Ginanjar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 08-May 12

Posted 14 November 2012 - 03:00 PM

hey,, i have problem too at page 115 (adding some filter logic)

i've follow code on book. here my code,
        private $_project = null;
	protected function loadProject($project_id){
		if($this->_project === null)
		{
			$this->_project=Project::model()->findByPk($project_id);
			if($this->_project === null)
			{
				throw new CHttpException(404,'The Requested project does not exist.');
			}
		}
		return $this->_project;
	}
	public function filterProjectContext($filterChain)
	{
		$projectId = null;
		
		if(isset($_GET['pid']))
			$projectId = $_GET['pid'];
		else
			if(isset($_POST['pid'])
				$projectId = $_POST['pid'];
				
		$this->loadProject($projectId);
		$filterChain->run();
	}
	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			'projectContext + create'
		);
	}


but when i try to access : http://localhost/lat...index.php/issue . i get an error 500

Quote

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

its anything wrong with my code?

thnks before :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users