Closed (won't fix)
Project:
Forum Access
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Nov 2011 at 18:50 UTC
Updated:
20 Jun 2012 at 15:37 UTC
In the latest version of git, flag links don't seem to know they are flagged.
Comments
Comment #1
quicksketchCould you provide steps to reproduce? This report is rather ambiguous.
Comment #2
aidanlis commentedSorry for the ambiguous report. I've got Flag, Flag Note, and Advanced Forum. I create a flag for comments and see a flag link appear on comments, but a user can flag each comment multiple times - the action never changes to unflag.
The flag is set up as non-global and can flag any content but their own content.
Thanks,
Comment #3
aidanlis commentedDiving deep into the flag module, I found that $GLOBALS['user']->uid was 1 when the comment links were being rendered! This stumped me majorly ...
I dove further with the help of debug_backtrace, and eventually found this nugget in the forum_access module (forum_access_link_alter() line 398):
This was triggered by a link_alter in one of our modules:
So ... not a bug in Flag.
Over to the forum_access module - what's the justification for switching to User 1 in the middle of a request? Can this be re-architected?
Comment #4
salvisThe comments are pretty clear. There's no use in repeating them again since you've already quoted them.
If I understand this correctly, then the issue is...
... and this is not working correctly for user 1. If the action changed as expected, also for user 1, then it would work correctly even under the circumstances that forum_access creates. Am I missing something?
The handling of comment links is very tricky, because the comment.module provides absolutely no support for adjusting access. We're coercing comments to follow the node access model, for example if a user is allowed to edit forum topics (in a given forum), then he should also be allowed to edit the comments under that topic. This means we need to force comment.module to give us the 'edit' link.
We also make an attempt to handle third-party links, but there's really no way for FA to decide whether a given third-party link requires 'view', 'edit', or 'delete' level access to be displayed. Until now I haven't been aware of any module that actually does provide third-party links, and this part of the FA code is not sufficiently tested. Still, I have to ask, why does Flag not change 'flag' to 'unflag' for user 1?
Comment #5
aidanlis commentedHi salvis,
Indeed, it is a tricky problem you are trying to solve.
The reason why using UID1 when generating the links breaks Flag is this: Flags can be configured to be per-person per-item, not just per-item ... think bookmarking a comment, or marking it as a favourite. The forum_access module replaces these per-person flags with uid1's flags.
So, for example, User 1 marks a comment as favourite. Suddenly, that comment is now visually favourited by all users on the site. Additionally, users can no longer favourite that comment, because clicking the link takes them to the unflag action. Further, all users get administrator access to unflag an item because the access control check is done by drupal_get_token and drupal_valid_token, both of which use the UID from the session.
Comment #6
salvisI understand — thank you for your research and explanations. This is a tough problem and I won't have any quick fix.
As usual, we'll have to look into the D7 version first. The D7 version uses a different approach and gets by without switching to user 1, but we still need to test this.
I won't be able to work on this before the end of the year...
Comment #7
salvisWhere do we stand here?
Have you been able to check whether the D7 versions get along better?
Comment #8
salvisComment #9
aidanlis commentedRE fixing this in D7 first: There's no report of users having this problem in D7 in the flag issue queue, and if we're not swapping to UID1 when generating the links then I don't see why it would be a problem.
On my D6 site, I just got bitten by this again on a different site implementing "like this" functionality. I was crawling through the source and I had this strange feeling of deja-vou. then I remembered this issue ...
Comment #10
salvis@aidanlis: Is #9 about D6 or D7?
Comment #11
aidanlis commentedI've edited for clarity
Comment #12
salvis@aidanlis:
Thank you for clarifying. You seem to be the only person trying to use Flag and FA on the same site, or IAC the only person who has this issue. I realize that this is a no-go for you. If you want to try to fix it, the tests and I will try to help, but it's too low on my priority list to have a chance that I get to work on it myself before D6 is obsolete.
We'll have to conclude that Flag and FA don't work together under D6. Sorry...