Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Lots of stuff that still needs to be done here:
* I haven't tested this at all because simpletest is horribly broken on my eeepc at the moment;
* I have no clue what to do with db_rewrite_sql or db_placeholders (which isn't actually used but the corresponding implode is a few times);
* There's at least one query with implode(' AND ', $match) that I didn't get around to replacing
I'll try to work on this some more when I get home.
Comment | File | Size | Author |
---|---|---|---|
#21 | book.dbtng_.followup.patch | 2.95 KB | John Morahan |
#18 | book.dbtng_.followup.patch | 2.64 KB | John Morahan |
#17 | book.dbtng_.followup.patch | 2.36 KB | John Morahan |
#15 | book.dbtng_.patch | 10.27 KB | John Morahan |
#12 | book.dbtng_.patch | 10.25 KB | John Morahan |
Comments
Comment #1
John Morahan CreditAttribution: John Morahan commentedFixed most of the above. I still haven't touched anything with db_rewrite_sql; setting CNR so someone can tell me how to deal with those. Note that this includes a fix to SelectQuery - it wasn't inserting a comma between multiple ORDER BY fields.
Comment #2
Crell CreditAttribution: Crell commentedThe multiple order by bug is handled in #302308: Multiple orderBy SQL syntax error, complete with unit test.
Comment #3
John Morahan CreditAttribution: John Morahan commentedOk, cool. Here it is without that part. Apply both patches to test.
Comment #4
John Morahan CreditAttribution: John Morahan commentedThe new docs-in-progress mention $query->addTag('node_access') so I added that.
I didn't see any obvious way to convert "SELECT * FROM {table}" to db_select, so I used this sort of thing:
That's hardly the best way to do this, though?
Comment #5
Crell CreditAttribution: Crell commented* is an expression, so you'd use $query->addExpression('*'); However, you really shouldn't use * anyway. Just add the fields you know you want. You get a more efficient query that way.
Comment #6
John Morahan CreditAttribution: John Morahan commentedI used $query->addExpression('*') as these are both public API functions so we don't know what specific fields their callers will need.
I vaguely recall that something was still wrong here but all the tests pass and I've let this sit on my laptop for too long.
Comment #7
Crell CreditAttribution: Crell commentedbook.module:
Line 213 and following, You can't chain most of db_select() because we need to return aliases. Sorry. :-( You can chain the execute()->fetchField(), and that can be on a single line like so:
Line 274 and following: No need to loop there. You can just do:
Line 280, that doesn't need to be a dynamic select, except for the annoyance of the IN clause. :-( Blargh. That's being worked on over in #314464: Convert db_placeholders() to DBTNG. I'm not sure how we want to handle that. The select query looks fine, it just should be unnecessary here.
Line 488, if you're going to explicitly specify a fetch mode as part of the method call then use ->fetchAssoc(), not ->fetch(PDO::FETCH_ASSOC). The former is easier to read. There are a couple of cases of that. (I think a lot of people are using fetchObject(), too, rather than the default of fetch().)
Line 501-505, the ->execute() should go on its own line, as should ->fields(). Like so:
Line 538 and 770, all built queries should be split across multiple lines, even if short. There are probably other instances of that I'm not catching at the moment, so please check for 'em.
Lines 1131 and following: I really dig the way you've abstracted the query to handle whatever depth is currently defined as the maximum. :-) Nicely done there.
book.pages.inc:
Line 213, another query that should be broken across multiple lines.
Thanks, John!
Comment #8
John Morahan CreditAttribution: John Morahan commentedThanks for the review! This one should be a bit better. I've left the db_placeholders one as a dynamic select for now - but actually, doesn't that need to be dynamic for node_access anyway?
Comment #9
John Morahan CreditAttribution: John Morahan commentedOh bloody hell, not this again. I *know* I attached a patch.
Comment #10
Crell CreditAttribution: Crell commentedHm. Yes, anything that needs node_access functionality (or any other query_alter) must be a dynamic select, and that is not going to change anytime soon. So yeah, if you need to tag it then it needs to be dynamic.
Comment #11
Crell CreditAttribution: Crell commentedPatch still applies with offset.
book.module line 1172 and following: We've since improved the API to make adding multiple fields easier. You can now use ->fields($tablename, array(the fields)). Should be an easy change.
Unfortunately, contrary to the test report in #9 I do get a number of simpletest failures on the book module with this patch. :-(
Comment #12
John Morahan CreditAttribution: John Morahan commentedSorry for the delay.
Comment #13
cburschkaPatch applies, book tests pass. I noticed no problem in normal usage of the book module either.
Comment #14
Crell CreditAttribution: Crell commentedThis won't work:
UpdateQuery::fields() only takes an associative array. The second line should be ->fields(array('bid' => $book_link['bid']).
In book_nodeapi_delete(), I don't get why we're fetching an associative array there. The legacy code was, but not for any valid reason as it's just a single column. :-) Let's switch that to an object so we can get rid of the options array there.
That's all I see on visual inspection. So close!
Comment #15
John Morahan CreditAttribution: John Morahan commentedComment #16
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.
The fact that the tests didn't catch that typo (associative array), suggests that the book tests need more work. Care to follow-up on that and to work on a book.test patch?
Comment #17
John Morahan CreditAttribution: John Morahan commentedHere's a test, along with a fix for the typo which actually was still broken (I misread Crell's comment, sorry). The test fails because of a different bug in book.module though, so marking CNW to prevent the bot reviewing it for now.
Comment #18
John Morahan CreditAttribution: John Morahan commentedLet's fix both issues together so there can be tests and they can pass too.
Comment #19
Crell CreditAttribution: Crell commentedThe bot likes it, and it looks OK on visual inspection.
Comment #20
Dries CreditAttribution: Dries commentedThe last code block of the test could use a code comment. Please be a bit more verbose. Thanks!
Comment #21
John Morahan CreditAttribution: John Morahan commentedAdded a comment.
Comment #22
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #24
Crell CreditAttribution: Crell commentedTagging.