Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
menu system
Priority:
Critical
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
13 Oct 2008 at 08:04 UTC
Updated:
7 Mar 2009 at 18:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedIndentation issues following arrays.
Comment #2
hswong3i commented@earnie: I think this is our new coding standard? E.g. includes/actions.inc, line 329:
Comment #3
Anonymous (not verified) commentedRight, but look at your patch in the browser. Some of the lines after closing )) for the fields(array( are not indented correctly.
Comment #4
hswong3i commented@earnie: Yes, get it and fixed :D
Comment #5
hswong3i commentedOooh... Some don't need to be too fancy :S
Comment #6
hswong3i commentedPatch reroll via CVS HEAD.
Comment #7
Crell commentedSubscribing...
Comment #8
Crell commentedAnd the test server doesn't like this.
Comment #9
hswong3i commentedWell... Its strange. I fetch code from CVS HEAD, apply patch, run installer with expert mode, activate simpletest, run simpletest for "menu", and all pass and looks good :-S
Anyway, re-submit the patch and hopefully the test server would like it :-)
Comment #10
Crell commentedFrom visual inspection:
Do we really have to duplicate the array in the query? It looks like the array that is already built is what should be passed into db_update() and db_insert() anyway.
The menu rebuild db_insert() is exactly the sort of place we want to be using a multi-insert statement. That should give us a nice performance bump.
Let's go ahead and do a full menu.inc DBTNG conversion as long as we're here.
Comment #11
hswong3i commentedHmm... I try to revamp with using
$itemdirectly, but failed. I guess it is because$itemcontain some other required keys. db_insert() and db_update() will not reference to database schema so it will build the RAW SQL with unexpected result. In order to have blind-insert or blind-update, we should use drupal_write_record() instead.BTW, as drupal_write_record() is now implement within common.inc so sometime it may still not yet include during early stage of bootscript. Moreover, drupal_write_record() coming with additional abstraction which must result with performance degrade. If we hope to boost up our libraries as much as possible, using db_insert() and db_update() seems to be a better choice.
P.S. Patch revamp with multi-insert, and I can FEEL the different during simpletest! Amazing! Maybe we can first pass this issue and follow up the others later?
Comment #12
dries commentedThe fact that you can 'feel' the difference is interesting and most promising.
We should make Simpletest report its total running time in the test summary. We'd be able to quantify what you feel and we'd be able to figure out who is using the fastest machine ... I created an issue for this: #329407: Make simpletest report running time
Comment #13
dries commentedI did some tests and I couldn't measure a significant performance impact when running the tests. Without this patch, running all tests took 21 minutes 18 seconds. With your patch it took 21 minutes 30 seconds.
Comment #14
Crell commentedI agree with sticking to db_insert()/db_update() here. In fact I'd like to go as far as eliminating drupal_write_record() entirely if possible. However, can we just unset the unneeded keys from the $items array and then pass it to insert?
Also, the fields() definition on the insert should just put one field per line. It's more lines that way, but is visually cleaner and more consistent with the rest of core, I think. (Dries & Angie can overrule me if they want there. I can see the argument to keep it as is.)
Comment #15
hswong3i commentedOh #329407: Make simpletest report running time is a good idea. Feeling is not accurate enough...
I give a try for this approach, but found that lines for explicitly unset unneeded keys is almost equal as that for explicitly use required keys. Moreover, those "unneeded keys" for db_insert() or db_update() maybe required for on going procedure, unset them may trigger other hidden issues. Finally, explicitly define keys seems much accurate and clear for debug and maintenance. (Please correct me if possible.)
Patch reroll based on above indent suggestion. Tested with MySQL simpletest and it looks fine.
Comment #16
hswong3i commentedKeep on update with DBTNG syntax. Just half-done. Keep as record.
Comment #17
dries commentedIf this patch is not complete yet, please mark it 'CNW'. Thanks, and keep up the good work, hswong3i.
Comment #18
hswong3i commentedLatest progress. I try my best (simpletest during development for 100+ times...), and most queries are now in DBTNG syntax. Some missing:
while ($item= db_fetch_array($result)) {is not able to revamp asforeach ($result as $item) {style. Once change it error is triggered. I don't know why this happened.db_rewrite_sql().Tested with MySQL + simpletest and pass all menu test. I need some help for the rest of revamp :S
Comment #19
dries commentedAt first glance this looks good. Would be great to get Crell's approval. :-)
Comment #20
hswong3i commentedI add the following comment for those incomplete, so simplify tracing:
Also minor fix some other syntax and coding style.
Comment #21
hswong3i commentedPatch reroll based on code cleanup. Also integrate with progress of #328110: Recoverable fatal error: Argument 3 passed to l() must be an array.
Patch via CVS HEAD, tested with MySQL + menu simpletest. All pass without error message.
Comment #22
hswong3i commentedAccording to commit of #328110: Recoverable fatal error: Argument 3 passed to l() must be an array, patch reroll, update, and focus on menu.inc only.
Patch via CVS HEAD, tested with MySQL + menu simpletest. All pass without error message.
Comment #23
Anonymous (not verified) commentedThe last submitted patch failed testing.
Comment #24
hswong3i commentedOoops... "Module list functionality" is failed. It is because passing $item as object into
_menu_delete_item(), but we use it as array. Quick fix with following code snippet:Also handle some more revamp from
while (...db_fetch_array())toforeach (...).Comment #25
hswong3i commentedComment #26
Anonymous (not verified) commentedObject to array conversion should happen with http://php.net/get_object_vars instead.
Comment #27
hswong3i commentedReference to #302207: DBTNG: book module, also handle db_query_rewrite() and some other minor stuff. Update "object to array" with get_object_vars(). Please refer to diff file for more information.
Comment #29
Crell commentedProbably mis-marked as CNW by the recent bot bug.
Comment #30
hswong3i commentedCrell: Not only about bot bug. forum.test coming with illegal (!?) statement, so the test fail. Patch updated, please refer to diff file for more information.
Comment #31
hswong3i commentedReroll via CVS HEAD.
Comment #32
lilou commentedYou can replace (twice) :
with :
Comment #33
hswong3i commentedYes, this looks more elegant :D
Comment #34
lilou commentedWrong patch :-(
Comment #35
hswong3i commentedOoops... How a silly mistake... Patch reroll :(
Comment #37
hswong3i commentedI double check with CVS HEAD and my testbed, simpletest should pass. Let's reroll once again.
Comment #38
dries commentedWhen I apply this patch, I get a WSOD (fatal error).
Comment #39
hswong3i commentedIt shouldn't be... I test it with PHP5.2 CVS HEAD, and all simpletest pass. Or any Apache error log message as reference?
Comment #40
dries commentedAfter another review, I decided to commit this patch. If necessary, we can follow-up with new patches. Thanks for your hard work hswong3i, and thanks to the many reviewers along the way. Committed to CVS HEAD.
Comment #41
dave reidI've got the following error now trying to install sqlite HEAD:
PDOException: UPDATE {menu_links} SET menu_name=:db_update_placeholder_0, plid=:db_update_placeholder_1, link_path=:db_update_placeholder_2, router_path=:db_update_placeholder_3, hidden=:db_update_placeholder_4, external=:db_update_placeholder_5, has_children=:db_update_placeholder_6, expanded=:db_update_placeholder_7, weight=:db_update_placeholder_8, depth=:db_update_placeholder_9, p1=:db_update_placeholder_10, p2=:db_update_placeholder_11, p3=:db_update_placeholder_12, p4=:db_update_placeholder_13, p5=:db_update_placeholder_14, p6=:db_update_placeholder_15, p7=:db_update_placeholder_16, p8=:db_update_placeholder_17, p9=:db_update_placeholder_18, module=:db_update_placeholder_19, link_title=:db_update_placeholder_20, options=:db_update_placeholder_21, customized=:db_update_placeholder_22 WHERE (mlid = :db_condition_placeholder_142) AND ( (menu_name <> :db_condition_placeholder_119) OR (menu_name IS NULL) OR (plid <> :db_condition_placeholder_120) OR (plid IS NULL) OR (link_path <> :db_condition_placeholder_121) OR (link_path IS NULL) OR (router_path <> :db_condition_placeholder_122) OR (router_path IS NULL) OR (hidden <> :db_condition_placeholder_123) OR (hidden IS NULL) OR (external <> :db_condition_placeholder_124) OR (external IS NULL) OR (has_children <> :db_condition_placeholder_125) OR (has_children IS NULL) OR (expanded <> :db_condition_placeholder_126) OR (expanded IS NULL) OR (weight <> :db_condition_placeholder_127) OR (weight IS NULL) OR (depth <> :db_condition_placeholder_128) OR (depth IS NULL) OR (p1 <> :db_condition_placeholder_129) OR (p1 IS NULL) OR (p2 <> :db_condition_placeholder_130) OR (p2 IS NULL) OR (p3 <> :db_condition_placeholder_131) OR (p3 IS NULL) OR (p4 <> :db_condition_placeholder_132) OR (p4 IS NULL) OR (p5 <> :db_condition_placeholder_133) OR (p5 IS NULL) OR (p6 <> :db_condition_placeholder_134) OR (p6 IS NULL) OR (p7 <> :db_condition_placeholder_135) OR (p7 IS NULL) OR (p8 <> :db_condition_placeholder_136) OR (p8 IS NULL) OR (p9 <> :db_condition_placeholder_137) OR (p9 IS NULL) OR (module <> :db_condition_placeholder_138) OR (module IS NULL) OR (link_title <> :db_condition_placeholder_139) OR (link_title IS NULL) OR (options <> :db_condition_placeholder_140) OR (options IS NULL) OR (customized <> :db_condition_placeholder_141) OR (customized IS NULL) ) - Array ( [:db_update_placeholder_0] => navigation [:db_update_placeholder_1] => 0 [:db_update_placeholder_2] => batch [:db_update_placeholder_3] => batch [:db_update_placeholder_4] => -1 [:db_update_placeholder_5] => 0 [:db_update_placeholder_6] => 0 [:db_update_placeholder_7] => 0 [:db_update_placeholder_8] => 0 [:db_update_placeholder_9] => 1 [:db_update_placeholder_10] => 1 [:db_update_placeholder_11] => 0 [:db_update_placeholder_12] => 0 [:db_update_placeholder_13] => 0 [:db_update_placeholder_14] => 0 [:db_update_placeholder_15] => 0 [:db_update_placeholder_16] => 0 [:db_update_placeholder_17] => 0 [:db_update_placeholder_18] => 0 [:db_update_placeholder_19] => system [:db_update_placeholder_20] => [:db_update_placeholder_21] => a:0:{} [:db_update_placeholder_22] => 0 [:db_condition_placeholder_142] => 1 [:db_condition_placeholder_119] => navigation [:db_condition_placeholder_120] => 0 [:db_condition_placeholder_121] => batch [:db_condition_placeholder_122] => batch [:db_condition_placeholder_123] => -1 [:db_condition_placeholder_124] => 0 [:db_condition_placeholder_125] => 0 [:db_condition_placeholder_126] => 0 [:db_condition_placeholder_127] => 0 [:db_condition_placeholder_128] => 1 [:db_condition_placeholder_129] => 1 [:db_condition_placeholder_130] => 0 [:db_condition_placeholder_131] => 0 [:db_condition_placeholder_132] => 0 [:db_condition_placeholder_133] => 0 [:db_condition_placeholder_134] => 0 [:db_condition_placeholder_135] => 0 [:db_condition_placeholder_136] => 0 [:db_condition_placeholder_137] => 0 [:db_condition_placeholder_138] => system [:db_condition_placeholder_139] => [:db_condition_placeholder_140] => a:0:{} [:db_condition_placeholder_141] => 0 ) SQLSTATE[HY000]: General error: 25 bind or column index out of range in menu_link_save() (line 2168 of /home/davereid/Projects/drupal-head/includes/menu.inc).Comment #42
dave reidRolling back this patch allows HEAD to be installed on sqlite. Marking as critical since this patch broke HEAD on sqlite.
Comment #43
dave reidFollowup issue for broken sqlite HEAD in #342725: Broken HEAD - Super long update queries.
Comment #45
Crell commentedTagging.