Posted by Dave Reid on April 19, 2010 at 4:33am
17 followers
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | theme system |
| Category: | bug report |
| Priority: | critical |
| Assigned: | dmitrig01 |
| Status: | closed (fixed) |
Issue Summary
1. Install core
2. Go to node/add/article
3. Go to admin/reports/dblog and see that there is a watchdog error message "Theme key "node_form" not found."
This should not be happening on a fresh install, or we need to downgrade this error message. This is absolutely messing on tests in XML sitemap that checks if the watchdog table doesn't have any errors or warnings during its tearDown() function.
Comments
#1
subscribe
#2
subscribe
#3
Subscribe
#4
Bonus points (but a separate bug): click the link (assuming the overlay is installed) to node/add/article?render=overlay
#5
The problem is coming from node.pages.inc+278, what is this supposed to be:
$form['#theme'] = array($node->type . '_node_form', 'node_form');#6
I've got this one. The problem is much deeper.
#7
I have tracked this issue to theme.inc
<?php// If an array of hook candidates were passed, use the first one that has an
// implementation.
if (is_array($hook)) {
foreach ($hook as $candidate) {
if (isset($hooks[$candidate])) {
break;
}
}
$hook = $candidate;
}
?>
If no $hook was found in the $hooks array then the last hook iterated through the foreach loop is put as the value of $hook. $hook = $candidate. The array passed as $hook contains two values: $node_type_node_form and node_form. There is no theme hook defined as either of these. So one of two things needs to happen (I think). There needs to be a theme implementation of node_form (Is this missing on purpose? It was available in 6.). Or there needs to be a graceful failout instead of logging a watchdog.
Thoughts?
#8
This is related to #596582: Remove remnants of theme_node_form(). It looks like theme_node_form was removed on purpose. Actually, looking further, the node_form looks like it's being replaced with node_edit_form. And, in fact, it looks like the whole $node-type.'_node_form' system no longer works like it was before. Maybe in the middle of a switch to using a single node_edit_form instead of distinct node type _node_form forms?
#9
I have noticed this at least for the last month (since alpha3), but didn't report it, since I thought someone else had. Sorry, I should've checked.
#10
dmitrig01: any chance on an update? Let us know what's up.
#11
subscribe
#12
seeing this also.
#13
I think this is the only solution then.
#14
fine with me. its easy enough to form alter and add a #theme
#15
Committed to CVS HEAD. Thanks.
#16
Indeed, the errors are gone. Thanks.
#17
Not sure whether this was the right fix.
Effectively, this means that the behavior for a single theme hook (string) is different to the behavior for theme hook suggestions (array).
That is, because http://api.drupal.org/api/function/drupal_build_form/7 automatically assigns $form_id as #theme hook, if #theme is not defined (which no longer is). In turn, this means that the node_form still has a #theme defined, and still points to a non-existing theme hook, but just because it's a single hook suggestion, instead of an array of suggestions, it "suddenly" doesn't throw a watchdog warning.
Now, after writing this down, I am sure this was the wrong fix.
#18
I believe this fix was okay. theme() is consistent in throwing a watchdog when a single passed $hook isn't implemented, or if none of the items in the array are implemented. drupal_build_form() only sets #theme if the $form_id exists as a hook in the registry. Perhaps restoring the functionality lost by #13 can be rolled into #757154: Base form_id via hook_forms() not taken into account for #validate, #submit, hook_form_FORMID_alter(), but with the registry checks that drupal_build_form() does?
#19
Automatically closed -- issue fixed for 2 weeks with no activity.