Trouble with CSTAT relationship and defaultScope in secondary model

I’ve got a bit of a confusing problem that I’d like your advice on.

I’ve got two models:

  • Site

  • SiteSurvey

I’ve also got a CSTAT relationship in Site that counts my SiteSurveys.

			'surveyCount' => array(self::STAT, 'Survey', 'siteId',



So far so good. SurveyCount is properly populated, I can print out the number of surveys and it’s accurate.

In addition, I’ve got a defaultScope in SiteSurvey that checks to make sure the user is only able to view site surveys for sites the user is allowed to view:

// SiteSurvey.php

public function defaultScope() {



		return array(

			'condition'=>'site.type = :type',





	else return array();


This code works fine if looking at a SiteSurvey grid as a sub user. And my surveyCount works great if an admin user looks at a site grid and looks at information about site surveyCounts. But if I look at a site grid as a subUser, I get the following error:

It looks like the CSTAT relationship isn’t honoring the defaultScope with parameter that I specified. Is that accurate? Any suggestions on ways I might be able to handle this?