Posted by rfay on August 10, 2011 at 5:58pm
18 followers
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | entity system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
If you remove all product types you get this on some pages. I'm not sure it's important, as it's an unusual occurrence, but :
Notice: Undefined index: commerce_product in field_info_instances() (line 682 of /home/rfay/workspace/commerce/modules/field/field.info.inc). Backtrace:
field_info_instances('commerce_product') commerce_product_reference.module:40
commerce_product_reference_field_extra_fields()
call_user_func_array('commerce_product_reference_field_extra_fields', Array) module.inc:819
module_invoke_all('field_extra_fields') field.info.inc:231
_field_info_collate_fields() field.info.inc:658
field_info_field_by_ids() field.attach.inc:603
field_attach_load('rules_config', Array) entity.controller.inc:633
EntityAPIControllerExportable->attachLoad(Array, ) rules.core.inc:36
RulesEntityController->attachLoad(Array, ) entity.controller.inc:230
EntityAPIController->load(, Array) entity.controller.inc:532
EntityAPIControllerExportable->load(, Array) common.inc:7448
entity_load('rules_config', , Array) entity.module:143
entity_load_multiple_by_name('rules_config', , Array) rules.module:603
rules_config_load_multiple(, Array) rules.plugins.inc:696
RulesEventSet->rebuildCache(Array, Array) rules.module:260
_rules_rebuild_cache(Array) rules.module:239
rules_get_cache('data') rules.module:232
rules_get_cache('event_init') rules.module:722
rules_invoke_event('init') rules.module:26
rules_init()
call_user_func_array('rules_init', Array) module.inc:819
module_invoke_all('init') common.inc:4942
_drupal_bootstrap_full() bootstrap.inc:1933
drupal_bootstrap(7) index.php:20
Comments
#1
This is a core problem. The attached patch works around this problem.
#2
Look sensible as far as I can see.
#3
+++ b/modules/field/field.info.inc@@ -678,7 +678,7 @@ function field_info_instances($entity_type = NULL, $bundle_name = NULL) {
- if (!isset($bundle_name)) {
+ if (!isset($bundle_name) && !empty($info['instances'][$entity_type])) {
return $info['instances'][$entity_type];
}
I think we need to use a ternary operator in the return value - otherwise, we're not entering the condition when we're supposed to.
Second, this looks important enough for me to require tests.
20 days to next Drupal core point release.
#4
This is the syntax I'm used to for this type of double-optional function which also makes the most sense to me. Adding tests.
#5
The last submitted patch, 1245332-field-info-intances-fix-returns.patch, failed testing.
#6
Revised patch, passes tests.
#7
Code looks good, however the test is wrong :
$instances = field_info_instances('test_entity');is always keyed by the bundles known for the entity type (known = exposed in hook_entity_info())#8
Isn't that what we're testing?
#9
Ooops, crosspost, my comment was for patch #4.
RTBC :-)
#10
Small change to the assertion messages, no functional change so leaving RTBC.
#11
Thanks!
Committed/pushed to 8.x, moving to 7.x for backport.
#12
#13
#14
Rerolled patch from #10 for D7.
I've also included p0 format patch for the benefit of those not using a git checkout of core.
#15
Moving to 'needs review'.
#16
The last submitted patch, field_info_instances_fix_returns-1245332-14-7.x.p0.patch, failed testing.
#17
To make a patch not be tested, name it like
field_info_instances_...-p0-do-not-test.patch
But anybody using the patch tool can use
patch -p1with a standard git patch.#18
Good call, though I don't believe it's possible to specify that -p1 flag with drush make
#19
drush make has handled git-style patches for many months now.
#20
But will they apply to a project that's not checked out from the git repo?
EDIT: Just tested that myself, and color me surprised.. it sure does. Thanks for the info on that Randy, I had no idea drush make would apply a git patch to a project that's downloaded rather than cloned from the repo. :)
#21
Yes, git patches are just
patch -p1patches. nothing special.Drush make added support for all regular git patches in the issue queue in #745224-132: Apply patches from git diff and git format-patch in July, 2011.
#22
At any rate, the patch in #14 does apply cleanly and resolves this issue.
I don't seem to be able to run the tests locally at all without them simply timing out and failing. Probably a server config issue I imagine, but I'm not clear why the one test is failing with the testbot, that shouldn't be affected by this patch at all as far as I can tell.
Queuing for re-test.
#23
#14: field_info_instances_fix_returns-1245332-14-7.x.patch queued for re-testing.
#24
Re-uploading D7 patch only.
#25
I have tested #24 and I can confirm that it seems to resolve the issue, thank you!
#26
Feel free to mark this issue as 'reviewed and tested by the community' then so we can get this fixed in Drupal 7. :)
#27
yup, same as for D8
#28
Weird. Why did it pass when you uploaded it?
#29
Bumping to d8 because it needs to go in there first
#30
My bad
#31
Committed and pushed to 7.x. Thanks!
#32
Automatically closed -- issue fixed for 2 weeks with no activity.
#33
FYI I did a fresh install of D7.12 and some modules. I deleted all content types and then got this message:
The content type Basic page has been deleted.
Error message
Notice: Undefined index: comment in field_info_instances() (line 687 of ../domain/modules/field/field.info.inc).
Notice: Undefined index: node in field_info_instances() (line 687 of ../domain/modules/field/field.info.inc).
Add content type
Name Operations
No content types available. Add content type.
I installed the patch in #24 and the error messages disappeared after the cache was cleared. So that worked, thanks :)
#34
it works for me too
#35
Did this ever make it to a stable release? I don't see a note anywhere
#36
It was committed to D7 on March 11, so is part of 7.14. The commit was http://drupalcode.org/project/drupal.git/commitdiff/f145e08cfd0c67f05ec8...