Copy fix to core bug: Forum count incorrect when using access control modules
carnage - July 2, 2009 - 13:05
| Project: | Advanced Forum |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
duplicate of this bug: http://drupal.org/node/113611#comment-1764488
however it applies to advanced forum as well since the same query is used.
I 'fixed' the problem in this module as its easier to do in here than in anywhere else, patch attached.
| Attachment | Size |
|---|---|
| adv_forum.patch | 667 bytes |

#1
This patch subtracts lines that don't exist... Is it a bad patch or am I missing something? Assuming it's a bad patch and you're meaning to add the lines, can you give me some idea of what it's doing? I don't speak regex.
Thanks,
Michelle
#2
:s Must have fed the files into diff in the wrong order...
http://drupal.org/node/242605 this post explains in detail whats going on
The idea for the fix is that this rewrites a query that has access control added to it to only select distinct rows.
The $regex regex finds the INNER JOIN to the node access table and changes it to inner join a sub query instead as the join is now a subquery its possible to restrict it to DISTINCT values per node, fixing the issue.
Basically add these lines:
$regex = '#INNER JOIN \{node_access\} (na ON na.nid = n.nid) WHERE (.+) AND #'; //finds the offending join and added conditions to where
$replace = 'INNER JOIN ( SELECT DISTINCT na.nid FROM {node_access} na WHERE \2 ) \1 WHERE '; //replaces with subquery including DISTINCT moving the where conditions into the subquery.
$sql = preg_replace($regex,$replace,$sql);
after the db_rewrite_sql.
#3
That seems reasonable. I'll need to take some time to give it a good test before applying it to 1.x since that's a stable branch. I'd appreciate it if someone else out there could test it as well.
Michelle
#4
3 weeks later, I gotta be honest. I don't see me getting time to do major testing with 1.x since I have my hands full with 2.x. Since I don't use access control modules, this isn't a priority for me, though I know it is for others. There's got to be someone else out there running node access modules that can give this a RTBC. Otherwise it's not likely to get in until 2.x.
Michelle
#5
If carnage or Michelle could please submit a propper patch then I would be very willing to test it. I can apply patches but I might choke heavily on inserting something "by hand" without understanding of what I am doing. ;)
#6
I discussed this on IRC with someone who's opinion I trust and he wasn't happy about the regex. Since I don't speak regex, I'm not thrilled about it, either. I'm hoping someone will come up with a better way of fixing this.
Michelle
#7
Ok. I'll stand put to test any patch that lands.
#8
Looks like there's a lot of work being done on this in #113611: Forum count incorrect when using access control modules . Once it's sorted, I'll copy the solution. :)
Michelle