Closed (fixed)
Project:
Activity Log
Version:
6.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Aug 2011 at 12:09 UTC
Updated:
4 Jan 2014 at 01:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
BogdanN commentedAdded a small patch to address this
Comment #2
icecreamyou commentedEach of the "entity groups" where this could be an issue has specific code to address this. For example, the code that finds users' relationships looks like this:
Additionally, 0 (zero) is a valid stream owner ID, and there could potentially be non-numeric values or negative values added in the future as well (which we already do for viewers). So even if we didn't catch the private group cases by the time they get to
$owners = $results['stream_owner'];the handling your patch adds isn't quite enough.So the real question is -- under what circumstances are people who are not group members able to see private group posts? What specific case has been missed? Specifically, what entity groups and for what event are relevant here?
Comment #3
BogdanN commentedHm, good point. I'll have a look tomorrow. I think the problem appeared when creating a rule for a new post in a group, for the acting user's relationships.
Comment #4
BogdanN commentedDone some debugging. At the time that function is called, og_private is always set to 0, regardless of reality. Hence the patch above - I know it's not the prettiest, but I don't think all required hooks have run before activity_log_eg_acting_user_rels_type is called
Comment #5
icecreamyou commentedWell there aren't any more hooks that would have been run by the time the system runs your code. But your patch uses og_public and right now all the entity group callbacks use og_private. Maybe switching to og_public in the entity group callbacks would work.
Comment #6
BogdanN commentedog_public is not set when entity callbacks are called
Comment #7
icecreamyou commentedHmm. Sounds like I'm going to have to dig into this one. What version of OG are you using?
Comment #8
ezra-g commentedWe have the core node access system/db_rewrite_sql() to enforce node access so that we don't have to write our own system. Changing title to reflect that the stream should enforce any node access restriction that uses the core node access system, not just OG access restrictions.
Here's a patch that implements hook_views_pre_render() to remove activity log messages from the view result set if the user doesn't have view access on the node that's discussed in the activity log message.
Note, this assumes that an activity log message about a node will always be of the target_type 'node'.
I tested this code by
a) Creating a private group
b) Adding a private discussion to a public group
and verified that those status messages were not displayed to an anonymous user but were displayed to a privileged user, while the anonymous user was still able to see messages that she should be able to see.
It would be great to get some more thorough testing here.
@IceCreamYou, it would be great if you could confirm my assumption about target_type :).
Raising priority to "major" since, as a security issue, this would prevent a stable release.
Thanks!
Comment #9
ezra-g commentedWith an empty() check on $view->result.
Comment #10
gregglesIf you are looking for a simple non-OG module to confirm this thing works, I suggest http://drupal.org/project/private
(also subscribe).
Comment #11
ezra-g commentedAdding Commons 2.0 Release tag.
Comment #12
icecreamyou commentedThanks for the patch, Ezra. A couple of things:
$result->activity_log_messages_target_type)? I'm pretty sure the alias is stored somewhere in the View object... something like$view->query->fields[$field]['alias']?array_unique()on$nidsthan to useDISTINCTin the query... NBD, but also the fewer database commands we use, the less I have to go look up when I port the module to Drupal 7. :-P(1) If we used a node access grant-style system instead of having a "viewer" column to control who can see activity messages, we *might* be able to keep it in sync with the node access control system.
(2) Rules events have to define the types of variables they use. Activity Log assumes that the first defined variable is the target entity. Since Rules event definitions are static, the array of which variables each event uses never changes, so the target type will always be consistent.
(3) As an example, Activity Log does this when unpacking a loaded message record in activity_log.module line 151. Note that the aids are stored with a leading and trailing comma, so you need to
array_filter()orarray_pop()/array_shift()afterexplode()ing. The aids are stored this way to make SELECT queries easier, so that for example you can do something likeSELECT mid FROM {activity_log_messages} WHERE aids LIKE '%%,%d,%%'where %d is an event ID. (There might be a more efficient way to store the relationship between events and messages. However, in theory, one event could map to multiple messages and one message could also map to multiple events. In practice, no event maps to more than one message. The idea was that one event record would correspond to each time a Rules event was triggered, but the way it actually got written was that each event record corresponds to each time a Rulesactionis triggered. I'm sure there is an opportunity for optimization somewhere in there.)Obviously this is an issue we'd all like to get resolved ASAP. I *think* I will be mostly available this weekend, and I'll try to remember to get on IRC when I'm near my computer. Ezra, I'd appreciate if you can address the issues above, or if you're not available this weekend I should be able to look into it.
Comment #13
ezra-g commentedThanks for the thorough response.
Yeah. I think given the timeline (2.0 release of Commons on Monday) we should avoid rearchitecting this complex system and stick with the approach here. We can evaluate whether it's worth re-architecting in the upcoming Commons sprints.
Agreed.
Gotcha. How can we reproduce a grouped status update?
I can give this some time later today, but given your familiarity here if you wanted to improve the patch here to account for that, it would be awesome.
That sounds like it's probably true ;), but not as high priority as the other fixes here (though we should fix it eventually).
DISTINCT() is a common MySQL function within Drupal, and I believe that MySQL is generally faster about this kind of data crunching than a built-in PHP function (at least that's the rule of thumb I generally use). So, I'm not sure I follow the "makes upgrade to D7" faster argument :).
We've got a friendly QA tester who will be available on Sunday, so I'd like to wrap this up one way or another today and integrate into a testable version of Commons with some fixes by tonight if possible. I think in worst case scenario, the latest patch with the ability to handle grouping would get us to the release, and we can come back and refactor afterwards.
Comment #14
icecreamyou commentedProbably the best way for this scenario would be to create a new Rule. You can probably clone or change the existing Rule that deals with creating new nodes in groups, and just change the grouping settings for each of its actions.
I committed an iteration of the patch from #9 to dev. I haven't tested it. Leaving this at "needs work" until someone can confirm that it works and the two remaining TODOs (documented in the patch) are addressed.
Comment #15
gregglesOne stylistic nitpick on the commit in #14 is that I wouldn't do this:
Commented out code makes it harder to see what's really going on. If you want to save that "just in case" then you can always go back in version control to get the version of the module from before the commit.
Here is the tree associated with the parent comment which has the code still present: http://drupalcode.org/project/activity_log.git/tree/84612ff77cc50ae8cfbb...
Comment #16
BogdanN commentedI might be missing something, but there's still the problem that the last patch only addresses views, whereas there's also the connection with digests, etc.
Comment #17
ezra-g commented> I might be missing something, but there's still the problem that the last patch only addresses views, whereas there's also the connection with digests, etc.
That's an important point.
At this point, we could retrofit a similar solution onto the digest functionality. In the long term, it seems ideal to have a more integrated solution.
Currently when I submit one node into 2 groups, I only see one status update about the first group. I'm not sure if this is a configuration issue or a bug where activity_log only records activity for the first group. @IceCreamYou, can you confirm?
Comment #18
icecreamyou commentedAgreed, I'll get rid of it the next time I take a look at that code (hopefully soon, when I finish the TODOs remaining from this issue).
Committed equivalent code to Digests. Since that part isn't using Views it isn't affected by the issues I mentioned for Activity Log.
Leaving this issue at Needs Work until those issues can be fixed:
Comment #19
gregglesre #18, I guess that was http://drupalcode.org/project/digests.git/commit/5e00bc7 ?
It's great, in my opinion, to link from commit to issue and from issue to commit to make it easy for folks to review the work and confirm why things were changed.
Thanks for your efforts!
Comment #20
icecreamyou commentedYes, I meant to do that... there's an equivalent issue in the Commons queue and I posted the commit to the Commons repo there which made me forget about this one. Normally I'd link both ways.
Comment #21
icecreamyou commentedMarking this fixed and moving the remaining work to #1260468: Refer to Views fields the right way when checking node access