book_location_down() has a critical bug when book pages have multiple revisions. you can get into an infinite recursion if the book pages are moved around such that if at any time in the revision history, there's a circular parent/child relationship between any 2 pages. before zen comes in and moves this from "critical" to "exotic" ;) keep in mind i only found this bug because it happened on the live site at my day job. i wasn't trying to break anything, it just happened through the normal course of reorganizing book pages on our site. :(
luckily, the solution is trivial. we're doing an INNER JOIN on the book and node table, but have completely forgotten about the vid field (revision id). :( book stores records for each vid, so when we're SELECTing, we grab *all* revisions of all pages that have ever had the current node as its parent. instead, we only want to be looking at the most current versions of book pages that have the current nid as their parent. so, we just need to add an WHERE n.vid = b.vid
clause to the INNER JOIN. patch attached (which applies cleanly to DRUPAL-4-7, and with a 5 line offset to HEAD).
please review/test and commit ASAP.
thanks!
-derek
Comment | File | Size | Author |
---|---|---|---|
#3 | book.patch_0.txt | 1.14 KB | Gerhard Killesreiter |
book-vid-infinite-recursion.patch | 1.16 KB | dww | |
Comments
Comment #1
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedlooks good to me, applied.
Comment #2
dwwkilles, i don't actually see any commits to book.module in cvs (either DRUPAL-4-7 or HEAD) that fix this bug. when you say "applied", what do you mean? ;) can you point to a cvs revision number, commit id, etc? thanks.
Comment #3
Gerhard Killesreiter CreditAttribution: Gerhard Killesreiter commentedyeah, forgot it. I have modified it, patch for HEAD is attached.
Comment #4
dwwcool, thanks. i was thinking afterwards that vid might be unique across nids, and that if so, that'd be better. judging from your patch, that seems to be the case.
Comment #5
Dries CreditAttribution: Dries commentedGood catch. Committed to CVS HEAD.
Comment #6
dwwkilles commited to DRUPAL-4-7 (as revision 1.361.2.4), dries to HEAD (as revision 1.367). the bug doesn't existin in 4.6.x, since there's no revision id in the book table until 4.7. this is hereby fixed. thanks folks.
Comment #7
(not verified) CreditAttribution: commented