Insert patch here.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 394476.menu_dbtng7.patch | 13.76 KB | berdir |
| #18 | 394476.menu_dbtng6.patch | 14.24 KB | berdir |
| #13 | 394476.menu_dbtng5.patch | 14.09 KB | berdir |
| #8 | 394476.menu_dbtng4.patch | 13.63 KB | berdir |
| #5 | 394476.menu_dbtng3.patch | 13.34 KB | berdir |
Comments
Comment #1
berdirAttached is a first patch, mostly static queries..
A few notes:
- I used fetchAssoc() and while (instead of foreach) all over the place because of: #423690-2: menu_link_maintain(), $op update critically broken.. I'm not sure if comment #3 of there would be the better approach.
- There are multiple range(0,1) queries which are just used to see if there is altleast a single row. Not sure if we can replace these with static queries..
- There were multiple "half-converted" queries, which missed the ":" in the key of the arguments array. It seems that one is not necessary, but I added it anyway to have it consistent
Edit: Phew, that patch is leet... "13.37 KB" ;)
Comment #2
Crell commentedAll built queries that have more than one chained method should be multi-line. Eg:
Sadly that will change the size of the patch. :-(
Comment #3
berdir- Converted those db_delete() calls to multi-line
- Removed the range stuff from those two queries in menu_node_prepare(). I don't think they're needed and save us two db_select() calls.
Comment #4
pwolanin commentedBased on discussion and benchmarking,
Is seems to be quite a bit faster to do this (or to set the fetch mode in the db_query() call):
versus:
see: #430986: Compare DB fetch options for speed.
Comment #5
berdirUpdated to use setFetchMode and foreach
Comment #6
pwolanin commentedInstead of calling setFetchMode(), other places in core the queries are called like:
or:
probably some of the complex queries shoudl be converte to db_select()?
Comment #8
berdir- Re-rolled
- Updated FETCH configuration
- Queries should only be dynamic if they need to, afaik.
Comment #9
pwolanin commentedpossibly this one query should be db_select():
But overall looks good.
Comment #10
Crell commentedThe only reason to make that query dynamic would be if we wanted to make the order by statement dynamically long based on the constant. That's a critical-path query, though, so it's probably not worth the performance cost.
That doesn't need to be dynamic. db_query_range() still works.
Elsewhere in core (and in this patch) we've been saying that if the placeholders array is 2 or more elements it should be broken across multiple lines. Let's do that here as well.
Otherwise looks good to me.
Comment #11
berdirThe second example is actually two arrays and each of them does only have a single value. I agree that the line is too long, but how should it be broken up?
Comment #12
Crell commentedAh! You are correct. My error, ignore that one.
Comment #13
berdirRe-roll with some minor improvements.
Comment #14
cburschkaQuick code-style question: Is it okay to put strings (ie. SQL queries) in double quotes if this is not made necessary by single-quoted strings inside the queries? Your patch uses double quotes for all queries.
Coding standards doesn't make an explicit ruling, but recommends using single quotes wherever possible.
Comment #16
cburschkaWow, that's a big failure. Almost a third of menu module fails.
Comment #17
berdirHum. I should it test locally before submitting the patch :-/
@Arancaytar:
The DBTNG Documentation can be considered as "DBTNG coding standards guidelines", and http://drupal.org/node/310072 always uses double quotes.
Comment #18
berdirMixed up :name and :menu parameter names.. renamed all of them to :menu to be more consistent.
Comment #19
pwolanin commentedSomehow I thought
db_query_range()was deprecated?Comment #20
berdirMe too, but.. #391340-59: Job queue API
Comment #21
Crell commenteddb_query_range() is not deprecated. I don't know why people keep thinking that. :-) It's the one bit of dynamic logic that we do allow on static queries, because it's fairly easy to do and is also very common, so it's a good optimization point.
Regarding quotation marks, traditionally queries always used double quotes because they almost always had single quotes in them as part of '%s'. Of course, that's no longer the case so we may want to revisit that. This is not the issue where we should do so, however.
Comment #23
berdirRe-roll of the above patch, no changes.
Comment #24
Crell commentedI don't see anything on visual inspection that would hold this up any longer. w00t!
Comment #25
dries commentedCommitted to CVS HEAD. Thanks!