views:

30

answers:

1

I'm using views_get_view_result to directly access the data in a view. I've stumbled upon this odd behavior where cck fields are prefixed with the first field name as a query optimization. Explained here.

What's bizarre though is that fields are named differently depending on whether I retrieve that data as Anonymous or as Admin. I'm pretty sure all my permissions are set up, and the view itself has no restrictions. What is going on here?

This is a big problem since I can't know how to retrieve a field. Here's a dump of the two view results. Notice that node_data_field_game_date_field_game_home_score_value != node_data_field_game_official_field_game_home_score_value.

// View as Admin
stdClass Object
(
    [nid] => 3191
    [node_data_field_game_date_field_game_date_value] => 2010-03-27T00:00:00
    [node_type] => game
    [node_vid] => 5039
    [node_data_field_game_date_field_game_official_value] => 0
    [node_node_data_field_game_home_team_title] => TeamA
    [node_node_data_field_game_home_team_nid] => 3396
    [node_data_field_game_date_field_game_home_score_value] => 68
    [node_node_data_field_game_visitor_team_title] => TeamB
    [node_node_data_field_game_visitor_team_nid] => 3442
    [node_data_field_game_date_field_game_visitor_score_value] => 118
)


// View as Anonymous
stdClass Object
(
    [nid] => 3191
    [node_data_field_game_date_field_game_date_value] => 2010-03-27T00:00:00
    [node_type] => game
    [node_vid] => 5039
    [node_data_field_game_official_field_game_official_value] => 0
    [node_node_data_field_game_home_team_title] => TeamA
    [node_node_data_field_game_home_team_nid] => 3396
    [node_data_field_game_official_field_game_home_score_value] => 68
    [node_node_data_field_game_visitor_team_title] => TeamB
    [node_node_data_field_game_visitor_team_nid] => 3442
    [node_data_field_game_official_field_game_visitor_score_value] => 118
)
A: 

Very weird behavior. Maybe it's a problem with content permission?

Brice Favre
Well, I don't think so... all field specific permissions are allowed, nodes are published, and I don't have any extra modules that would interfere - it's a pretty fresh install. I have a views_embed_view right after this, and both users display all fields correctly. But... just noticed another anomaly where table grouping works for Admin but does not for Anon. Disabling grouping does not fix the original problem.
AK
Actually on further investigation you were right, disabling Content Permissions fixed it!
AK
I dislike this module, too much trouble for so many features.
Brice Favre

related questions