Closed (fixed)
Project:
Flag
Version:
7.x-3.6
Component:
Flag core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Oct 2015 at 15:13 UTC
Updated:
28 Oct 2015 at 13:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
blanca.esqueda commentedFor some reason the if statement to check the comment add form is not working. I assume it was working before or maybe it still works for some specific cases.
The next condition is always false:
$entity_id is not empty but its value is 'new' for the comment add form.
And $flag->fetch_entity($entity_id) neither is empty or null, for the comment add form it generates an array:
stdClass Object
(
[nid] => 6
[name] =>
[mail] =>
[homepage] =>
[subject] =>
[comment] =>
[cid] =>
[pid] =>
[language] => und
[uid] => 0
[node_type] => comment_node_discussion
)
Including $entity_id == 'new' to the condition statement resolves this issue.
Comment #3
joachim commentedThanks for the patch!
Fix makes sense.
For the look of the thing, I think I would have put the check for 'new' before calling $flag->fetch_entity(), because when you read that expression it looks like that's going to incur a query. It turns out it doesn't, as it has a special case for 'new' as well. But I think this patch is fine as it is -- I'll commit it later.
It also looks like from a read of the code that the node case has the same problem.
Comment #4
joachim commentedFixed. Thanks again!
Looking at this area of code again, I think there are other bugs here.
If 'access_author' is NOT 'others', we return NULL, which means 'no opinion'. No further checks are done, so if the setting is 'node_own' or 'node_others', then it's being ignored.
I'll file a new issue for that: #2592435: flag on new comment form doesn't take node authorship access options into account.
There's also the same problem you found, but for nodes: #2592429: flag access for new nodes doesn't take into account the nid being set to 'new'