This appears to be because the _submit handler is never called since the form is directly added into another form.

STR:
1) Navigate to admin/config/search/xmlsitemap/settings
2) Click 'Menus' then 'Main Menu'
3) Choose to include the item in the sitemap.
4) Save

On the menus tab, Main Menu should not be 'Included' but will instead be 'Excluded.'

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Status: Active » Needs review
FileSize
1.1 KB

Status: Needs review » Needs work

The last submitted patch, 801894_1_xmlsitemap_options_do_not_save.patch, failed testing.

Dave Reid’s picture

Title: XML Sitemap does not save "include" or "exclude" on settings form » hook_menu_update() not called when modules alter the menu edit form
Project: XML sitemap » Drupal core
Version: 7.x-2.x-dev » 7.x-dev
Component: xmlsitemap.module » menu system

Ok this is really crappy. So hook_menu_update() only executes if you change either the menu title or description fields. Any other modules that add form items to the menu edit form are SOL about the hooks getting executed if only those fields are changed.

Dave Reid’s picture

Status: Needs work » Needs review
FileSize
769 bytes

The reasoning for this patch is menu_save() uses db_merge() to update the menu title and description. If modules have altered the menu edit form and the users changes those fields but not title or description, the db_merge() query will return 0 since no records were updated, and not SAVED_NEW or SAVED_UPDATED. This prevents the hook_menu_update() from being invoked.

Dave Reid’s picture

Issue tags: +Novice
Dave Reid’s picture

Issue tags: +xmlsitemap

This affects the XML sitemap module for D7. Anyone up for a quick review?

Dave Reid’s picture

Priority: Normal » Major

This is a broken hook, so marking as major.

Dave Reid’s picture

Assigned: Unassigned » Dave Reid
Dave Reid’s picture

sun’s picture

Title: hook_menu_update() not called when modules alter the menu edit form » SAVED_UPDATED is not always SAVED_UPDATED
Component: menu system » base system
Issue tags: -Novice
FileSize
9.31 KB

This affects a bit more than just menu_save(). It would be wrong to change drupal_write_record(), but we want to adjust similar code accordingly.

Dave Reid’s picture

Status: Needs review » Reviewed & tested by the community

Good catch sun! Looks good that the same bug is fixed in similar places, although it doesn't look like they affect hooks like the menu chunk does.

webchick’s picture

Issue tags: +Needs tests

Needs tests to make sure we don't break this again.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
David_Rothstein’s picture

Looking at the patch, I don't understand why it needs to change any form submit handlers? It seems like anywhere this issue occurs, it should always be fixed inside the corresponding API function. And in some cases - for example, filter_format_save() - I know that the API function already handles this situation, so we shouldn't need to change anything in the filter.module here.

We should also add documentation that menu_save() now has a return value...

Otherwise, looks great.

sun’s picture

David, that almost translates into directly changing drupal_write_record() to always return one of both constants.

I'm not sure whether API functions should be changed in a way that callers don't have to care. If we want to do this, then we don't have to change gazillions of API save functions, but can fix drupal_write_record() once for all instead.

sun’s picture

@Dave: Do you still tackle this one?

I'd like to hear feedback from base system maintainers on how to move forward here.

Dave Reid’s picture

Yeah I can work on re-rolling this tomorrow.

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
1.6 KB

I looked into this a bit and I actually don't think the bug exists anymore.

If I'm right, there isn't much to do here anymore except clean up any code that previously existed to work around this bug.

Also, it's a somewhat disturbing fact that db_merge() returns either MergeQuery::STATUS_INSERT or MergeQuery::STATUS_UPDATE, but we have lots of code in core that assumes its return value should be checked against SAVED_NEW or SAVED_UPDATED instead (i.e., relying on the fact that those constants happen to have the same numerical values)...

Dave Reid’s picture

Well shiver me timbers, I'm glad to see it got fixed a little more upstream in the code recently. We should maybe add tests that will assert that STATUS_INSERT == SAVED_NEW and STATUS_UPDATE == SAVED_UPDATED then.

Anonymous’s picture

#19 would be a useful stopgap, but any code that calls db_merge() and doesn't use MergeQuery::STATUS_* to check the results should be changed. if its too late in the cycle, so be it.

sun’s picture

Why on earth do we have two new constants that completely duplicate existing ones we already had for years?

David_Rothstein’s picture

Priority: Major » Normal
FileSize
6.91 KB

Good question. My guess is because the database layer was written to be independent of the rest of Drupal, so it only uses constants which it defines itself? That is kind of annoying in a situation like this, but getting rid of that duplication sounds too late for D7.

However, there is no reason we can't modify all callers to use the correct constants and check them appropriately; that is not an API change at all (especially given that they are numerically equivalent).

The attached patch should take care of all necessary cleanup. Also, I think we've determined that there is no longer a serious bug here, so I'm downgrading the priority.

mgifford’s picture

Assigned: Dave Reid » Unassigned
Issue summary: View changes
Status: Needs review » Needs work

No longer applies.