Lazy loading problem (I think)

Because my development environment is xampp on Window XP and the production environment is a shared unix server, I decided to upload my incomplete application to the production server just to see what issues I might run into. Most of the problems I experienced were expected and easily fixed. However, one problem has got me completely baffled.

I do not have any problems with this on the testing server, but after I uploaded the application to the production server, I get the following error when I try to view my community model:


PHP Error

Description


include(communityPlan.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

Source File


/home/farberam/public_html/BuilderApp/framework/YiiBase.php(341)


00329:      * @param string class name

00330:      * @return boolean whether the class has been loaded successfully

00331:      */

00332:     public static function autoload($className)

00333:     {

00334:         // use include so that the error PHP file may appear

00335:         if(isset(self::$_coreClasses[$className]))

00336:             include(YII_PATH.self::$_coreClasses[$className]);

00337:         else if(isset(self::$_classes[$className]))

00338:             include(self::$_classes[$className]);

00339:         else

00340:         {

00341: include($className.'.php');

00342:             return class_exists($className,false) || interface_exists($className,false);

00343:         }

00344:         return true;

00345:     }

00346: 

00347:     /**

00348:      * Writes a trace message.

00349:      * This method will only log a message when the application is in debug mode.

00350:      * @param string message to be logged

00351:      * @param string category of the message

00352:      * @see log

00353:      */


Stack Trace


#0 /home/farberam/public_html/BuilderApp/framework/YiiBase.php(341): autoload()

#1 unknown(0): autoload()

#2 /home/farberam/public_html/BuilderApp/framework/db/ar/CActiveRecord.php(352): spl_autoload_call()

#3 /home/farberam/public_html/BuilderApp/framework/db/ar/CActiveFinder.php(185): model()

#4 /home/farberam/public_html/BuilderApp/framework/db/ar/CActiveFinder.php(51): CActiveFinder->buildJoinTree()

#5 /home/farberam/public_html/BuilderApp/framework/db/ar/CActiveRecord.php(239): CActiveFinder->__construct()

#6 /home/farberam/public_html/BuilderApp/framework/db/ar/CActiveRecord.php(108): Community->getRelated()

#7 /home/farberam/public_html/BuilderApp/public_html/protected/controllers/CommunityController.php(61): Community->__get()

#8 unknown(0): CommunityController->actionView()

#9 /home/farberam/public_html/BuilderApp/framework/web/actions/CInlineAction.php(47): ReflectionMethod->invokeArgs()

#10 /home/farberam/public_html/BuilderApp/framework/web/CController.php(300): CInlineAction->run()

#11 /home/farberam/public_html/BuilderApp/framework/web/filters/CFilterChain.php(133): CommunityController->runAction()

#12 /home/farberam/public_html/BuilderApp/framework/web/filters/CFilter.php(41): CFilterChain->run()

#13 /home/farberam/public_html/BuilderApp/framework/web/CController.php(1049): CAccessControlFilter->filter()

#14 /home/farberam/public_html/BuilderApp/framework/web/filters/CInlineFilter.php(59): CommunityController->filterAccessControl()

#15 /home/farberam/public_html/BuilderApp/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter()

#16 /home/farberam/public_html/BuilderApp/framework/web/CController.php(283): CFilterChain->run()

#17 /home/farberam/public_html/BuilderApp/framework/web/CController.php(257): CommunityController->runActionWithFilters()

#18 /home/farberam/public_html/BuilderApp/framework/web/CWebApplication.php(324): CommunityController->run()

#19 /home/farberam/public_html/BuilderApp/framework/web/CWebApplication.php(121): CWebApplication->runController()

#20 /home/farberam/public_html/BuilderApp/framework/base/CApplication.php(135): CWebApplication->processRequest()

#21 /home/farberam/public_html/BuilderApp/public_html/index.php(13): CWebApplication->run()




This is the last thing in the application log prior to the error:


10:37:38.203869 	trace 	system.db.ar.CActiveRecord 	


lazy loading Community.communityPlans

in

/home/farberam/public_html/BuilderApp/public_html/protected/controllers/CommunityController.php

(61)

in /home/farberam/public_html/BuilderApp/public_html/index.php (13)

Now, I know communityPlan.php exists and the permissions are correct. I have no problem viewing a communityPlan. That’s why this error doesn’t seem to make any sense to me. Am I missing something obvious?

Here is the actionView for my community model. The commented code is the solution I used to get around this problem, but would like to know if there is something wrong with the original code.




	public function actionView($id)

	{

		$community = $this->loadModel($id);

		$communityPlans = $community->communityPlans;


/*

		$criteria=new CDbCriteria;

		$criteria->condition="communityID='$id'";


		$communityPlans = CommunityPlan::model()->findAll($criteria);

*/


		if(isset(Yii::app()->user->userLevelID))

			$myCommunities = Community::model()->getSalesPersonCommunities();


		

		$this->render('view',array(

			'model'=>$community,

			'communityPlans'=>$communityPlans,

			'myCommunities'=>$myCommunities,

		));

	}



Here is the relations() function:


	public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'location' => array(self::BELONGS_TO, 'Location', 'locationID'),

			'salesPerson' => array(self::BELONGS_TO, 'User', 'salesPersonID'),

			'users' => array(self::HAS_MANY, 'User', 'communityID'),

			'communityPlans' => array(self::HAS_MANY, 'communityPlan', 'communityID',

				'condition'=>'communityPlans.deleted=\'f\''),

		);

	}



Thanks in advance for your help.

I noticed that your class naming isn’t consistent (Community vs. communityPlan), which could cause you issues in linux. Is the file in fact named “communityPlan.php” and not “CommunityPlan.php” (consistent with the other filenames you mention)?

Edit: Also just noticed the same inconsistency in your code:


$communityPlans = CommunityPlan::model()->findAll($criteria);

vs


array(self::HAS_MANY, 'communityPlan',

Dude, that was it! I knew it was something obvious I was overlooking <_<

Thanks!

Is the only possible issue you have changing platform: case sensitive file system.

The best solution is to use a workstation with a case sensitive file system, if you cannot, pay lot of attention to the file names.

Yep. The the case sensitivity was the main issue I anticipated and had taken care of when I first uploaded to the production server. But, for some reason, I just kept overlooking this one. That’s the benefit of having another pair of eyes take a look at it. :)