Regression: node_types_rebuild should rebuild menu

beeradb - September 10, 2008 - 03:54
Project:Drupal
Version:7.x-dev
Component:node system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

Ran into this issue when programmatically creating node types for book.test. Reposting my synopsis here:

After calling drupalWebTestCase::drupalCreateContentType() I have to do a menu_rebuild() to go to 'node/type/$type'. This rebuild is typically handled by node_type_form_submit which is never called in this context.

There are three options here...

  • The menu_rebuild should be moved to node_types_rebuild.
  • A menu_rebuild should be added to drupalCreateContentType()
  • The menu_rebuild should be the tests responsibility to invoke, in this context

After a chat with chx in irc, he indicated that the menu_rebuild should be moved to node_types_rebuild, and all instances of node_types_rebuild and menu_rebuild called together should be updated. This patch does that.

marking critical, since the critical issue #299132: TestingParty08: book node types now relies on this patch.

AttachmentSizeStatusTest resultOperations
node_types_rebuild.patch2.57 KBIdleFailed: Failed to apply patch.View details | Re-test

#1

matt2000 - October 12, 2008 - 03:23

reporting that patch applies cleanly

#2

swentel - November 11, 2008 - 12:05

Simple reroll, previous applied with some offsets (don't credit me)

AttachmentSizeStatusTest resultOperations
node_types_rebuild.patch2.71 KBIdleFailed: Failed to apply patch.View details | Re-test

#3

Arancaytar - November 13, 2008 - 10:12

Patch looks good code-style and comment-wise - if Testbot gives it the go, mark it RTBC.

#4

beeradb - November 14, 2008 - 20:06
Status:needs review» reviewed & tested by the community

#5

beeradb - November 14, 2008 - 20:06

TestBot likes it, so does Arancaytar. There was much rejoicing.

#6

System Message - November 16, 2008 - 22:00
Status:reviewed & tested by the community» needs work

The last submitted patch failed testing.

#7

lilou - November 17, 2008 - 13:43

#8

lilou - November 17, 2008 - 13:44
Status:needs review» reviewed & tested by the community

Back to #4

#9

System Message - November 17, 2008 - 13:44
Status:reviewed & tested by the community» needs work

The last submitted patch failed testing.

#10

swentel - December 25, 2008 - 13:02
Status:needs work» needs review

Chasing HEAD.

AttachmentSizeStatusTest resultOperations
node_types_rebuild_0.patch2.72 KBIdleFailed: Failed to apply patch.View details | Re-test

#11

swentel - December 25, 2008 - 14:01
Status:needs review» reviewed & tested by the community

Marking rtbc, see #3, #4 and #8

#12

webchick - January 22, 2009 - 05:01
Status:reviewed & tested by the community» fixed

Committed to HEAD. Thanks!

#13

moshe weitzman - January 22, 2009 - 12:53

I'm not so sure this is a good idea. When programmatically creating, you might create a few at a time and there is no reason to inflict multiple menu_rebuild() in this case. A programmer can handle some cache flush and menu rebuild himself. My .02

#14

webchick - January 22, 2009 - 16:21

@moshe: I don't think that's a problem, because node_type_save() doesn't called node_types_rebuild(). So people doing practical mass-importing of content types as part of a data import script or something will still have to rebuild the cache manually, which I think is fine for the reasons you outline.

However, when creating SimpleTests, clearing the cache ends up being one extra thing you need to remember when writing tests, so it's nice to put in a shortcut for these people when using drupalCreateContentType(). While it's possible a test creates 50 content types before doing its thing, I don't think that's the norm.

And personally, even when I am programmatically creating content types, I find that I always remember the node_types_rebuild() but end up forgetting the menu_rebuild() which puts the types under "Create content" like it ought to, so coupling them is a nice DX improvement, IMO.

That said, if you still think this is a bad idea, let's discuss it. :)

#15

moshe weitzman - January 22, 2009 - 19:01

thanks webchick. makes sense.

the core problem is that menu_rebuild() is brutally expensive. i'll pester the menu folks to give that some attention.

#16

System Message - February 5, 2009 - 19:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#17

sun - June 11, 2009 - 05:50
Title:node_types_rebuild should rebuild menu» Regression: node_types_rebuild should rebuild menu
Status:closed» active

That, we have to revert. Menu system and Node system are two independent systems. If you want to, we can merge node types into the menu system or the menu system into node types. But as of now, these systems work and act separately.

See also http://api.drupal.org/api/function/menu_execute_active_handler/7 for an alternative solution.

#19

catch - July 3, 2009 - 19:59
Status:active» needs review

Here's a straight revert, then we can continue over at #193366: execute various rebuilds when modules are submitted for the performance issue itself.

AttachmentSizeStatusTest resultOperations
menu_rebuild_revert.patch2.61 KBIdlePassed: 12880 passes, 0 fails, 0 exceptionsView details | Re-test

#20

EvanDonovan - July 3, 2009 - 21:39

Thanks for this. I don't understand the technical details of what's happening here, but I hope the performance outcome will be beneficial.

Oh, and subscribing :)

#21

catch - July 3, 2009 - 22:20

This won't have a big performance impact, but it decouples the menu_rebuild() from the node_types_rebuid() so we can use menu_rebuild() more selectively elsewhere.

#22

webchick - July 10, 2009 - 06:26

I'll try and look at this tomorrow.

#23

sun - September 10, 2009 - 22:07
Status:needs review» reviewed & tested by the community

#24

webchick - September 10, 2009 - 22:10
Status:reviewed & tested by the community» fixed

Sorry, thought I had reverted this awhile ago. Committed to HEAD.

#25

EvanDonovan - September 10, 2009 - 22:55

Thanks!. Does this still have relevance to #193366: execute various rebuilds when modules are submitted, which has been RTBC for D6 since sun reviewed it last month? I would love it if that patch can make it into the next release of D6, as well as D7, of course. (I have been using #193366: execute various rebuilds when modules are submitted in production for months on a D6 site with 100+ modules and no known ill effects.)

#26

webchick - September 11, 2009 - 00:10

I don't think it has any bearing. The other patch simply moves the rebuilding to the submit button of the modules page rather than the display of it.

#27

EvanDonovan - September 12, 2009 - 03:46

Ok, great. I only asked b/c of catch's comments in #19.

#28

System Message - September 26, 2009 - 03:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.