Problem
1. After changing the name of the article content type from "article" to "nyhed", the following error occurs on the following path: #overlay=admin/structure/types/manage/nyhed/fields.
Error: Notice: Undefined index: nyhed in _field_ui_bundle_admin_path() (line 314 of /home/www/xxx/modules/field_ui/field_ui.module).
2. When the affected machine name is saved in the $_SESSION['node_overview_filter'] used at path /admin/content
Proposed solution
This is cache issue. We should change function node_type_form_submit() in modules/node/content_types.inc. We need to add
field_cache_clear();
$_SESSION['node_overview_filter'] = array();
after node_types_rebuild();
Comments
Comment #1
Anonymous (not verified) commentedThe error isn't persistent, when I go to the mentioned path now, no error occurs.
I'm thinking it could be a cache issue, as the error occured directly after the change. If this is correct I would class the error as minor, however I still think an error like this shouldn't occur, even if it goes away by itself.
Comment #2
furamag commentedI'm able to recreate this issue. This is cache issue. We should change function node_type_form_submit in modules/node/content_types.inc. We need to add
after
This fix works for me.
Comment #3
callison commented@furamag: Can you submit a patch?
Comment #4
marcingy commentedWe don't need to clear the data cache only the info cache. Patch attached.
Comment #5
callison commentedLooks good to me. Just a note for anyone else trying this - It's the machine name of the content type that causes the issue, not the human readable one.
Comment #6
dawehnerComment #7
dries commentedWhile this looks like it would fix the problem, I wonder if it is a complete solution. For example, don't we need to clear the field info cache when we delete a node type?
Comment #8
Kjartan commentedI can not reproduce this for 8.x, but its still there in 7.x. The earlier patch fixes the issue so should be good to commit.
To Dries' point there is no error on delete, but I agree that we should probably clear relevant caches even if there isn't an obvious way to trigger php notices.
Comment #9
enrico200165 commentedAfter changing the machine name of a content type it is impossible to create new content of that type, if I try I land on the general Add Content page.
Besides code fixes, is there any (manual) way to fix this issue now so my site returns usable?
Should I post this as a separate issue? (I do not see any error messages about index)
Comment #10
bobbyaldol commented@furamag
Can you tell us how you recreated the issue...That would help a lot
Comment #11
jaredcampbell commentedI had this same (or at least very similar) problem. When I changed the machine name of a content type and navigated to /admin/content I received the following error message:
"Notice: Undefined index: venue in node_filter_form() (line 177 of /home/district/public_html/district-trivia.com/modules/node/node.admin.inc)."
I believe I got this error message because my filter in /admin/content was currently set to the content type's old machine name. I fixed this by doing the following:
1. Changed the content type back to the original machine name
2. Went to /admin/content and clicked "Reset"
3. Changed the content type back to the new, desired machine name
4. Went to /admin/content and the error message was gone
Then I realized I had to manually update all of my views to point to the new content type. Voila! Everything appears to be working.
Comment #12
sivaji_ganesh_jojodae commentedI don't see any issues with renaming the machine name of content types. I'm still able to create new contents after changing its machine name.
Anyway I have added call to field_cache_clear() in node_type_form_submit() as it is believed to fix the issue for those who are able to reproduce it.
Besides I have added line to clear filter in page /admin/content for the case mention in comment #11.
Patch addressing the same has been attached. Rolled against branch 7.x.
Comment #13
sivaji_ganesh_jojodae commentedUpdated issue summary
Comment #14
parthipanramesh commentedI tested the latest patch and I am not getting any errors when I change name of the article content type. So it seems to work fine! Thank you!
Comment #15
David_Rothstein commentedLike #12 I can't reproduce the original issue (the one that's supposed to require the field_cache_clear()); is it still reproducible? And if we do need a field_cache_clear() there, do we need something equivalent in Drupal 8?
The second issue (with the admin/content filters) I can reproduce, and it would be Drupal 7 only. But if we clear the filters every single time a content type is saved, that's going to be extremely annoying for site administrators; they'll lose their filters completely even though 99% of the time the selected filters weren't even such to have triggered this bug. We should only clear the content type filter, and only when necessary (or alternatively, never clear it but add code on admin/content to handle the possibility of the filters in the session no longer existing; that would likely be a more robust fix).
Comment #16
balagan commentedI had a drupal 7.23 installed, where this problem occured. I wanted to try the patch and installed the current (7.34) core, where I cannot reproduce the error. I guess it is fixed.
Comment #17
balagan commentedSorry, I did not mean to change the component.
Comment #18
sowmiya.S commentedHi,
I have tested, this issue with patch in my local drupal, itz working fine.
Comment #19
hgoto commentedI tested this.
- The issue 1 cannot be reproduced.
- On the other hand, issue 2 can be reproduced.
So my recognition is the same as David_Rothstein's.
The patch #12 works well but I agree with #15.
The error only occurs in
admin/contentpage and should be handled there rather than the content type edit form. I tried creating a patch to handle the issue in theadmin/contentpage and would like someone to review this. Thank you.Steps to test the patch:
1. Open
admin/contentpage and filter content type to article.2. Open
admin/structure/types/manage/articlepage and change the machine name, e.g, "nyhed".3. Revisit the
admin/contentpage. You can see an error message like "Notice: Undefined index: type in node_filter_form()". (You can reproduce the issue.)4. Apply the patch.
5. Redo the steps 1 to 3. You'll find the error disappears.
Comment #20
stefan.r commentedMarking Novice for the manual testing, confirmation that #15 has been addressed, and issue summary update
Comment #21
skt-001 commentedthere is no issue persist in any updated version of 7.x and for 7.x #19 fixes the issues. RTBC+1
Comment #22
poker10 commentedThis was not committed to D8+, therefore removing the backport tag. If I read that correctly, the issue 2 is only a D7 problem.
As this is a bug, we should probably add a simple test to demonstrate the problem (and no manual testing will be needed afterwards). Moving to NW.