I am building a site where you can do a search for registered users and view their profiles. For this I wrote a ’GetSearchResults’ snippet.
I fetch the users like this:
$myQuery = $modx->newQuery('modUser');
$myQuery->leftJoin('modUserProfile', 'Profile'); //class, alias
$myQuery->leftJoin('modUserGroupMember', 'UserGroupMembers');
$myQuery->where(array(
'modUser.active' => 1,
'UserGroupMembers.user_group' => 2
));
$gtusers = $modx->getCollection('modUser', $myQuery);
Filtering happens in PHP. Because it seems unnecessary to do the database operation over and over again, I thought I’d add this:
$modx->cacheManager->set('GTUSERS', $gtusers)
However, this gives me: Fatal error: Nesting level too deep - recursive dependency? in /customers/4/c/1/geregistreerdetolken.nl/httpd.www/core/xpdo/cache/xpdocachemanager.class.php on line 878
I tried to var_dump the $gtusers array but that sort of froze my browser. What I could see is that the array is enormous and it seems filled with entries that have nothing to do with a user and his profile, like all kinds of config settings and lexicon entries and other stuff that I didn’t even recognize.
The search function worked fine until I tried to cache results, so the query must be doing what I want it to. But it seems I get a lot of additional and unwanted results with it, if that makes any sense. And I guess this makes the overall search result so bloated that it causes the cachemanager to stumble. Why is this happening? What did I pluck from the database to create this gigantic array? And is there any way to narrow it down?