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
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rfay’s picture

Project: Commerce Core » Drupal core
Version: 7.x-1.x-dev » 8.x-dev
Component: Commerce » entity system
Status: Active » Needs review
Issue tags: +Needs backport to D7
FileSize
556 bytes

This is a core problem. The attached patch works around this problem.

marcingy’s picture

Status: Needs review » Reviewed & tested by the community

Look sensible as far as I can see.

sun’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests
+++ 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.

Dave Reid’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
2.88 KB

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.

Status: Needs review » Needs work

The last submitted patch, 1245332-field-info-intances-fix-returns.patch, failed testing.

Dave Reid’s picture

Status: Needs work » Needs review
FileSize
3.65 KB

Revised patch, passes tests.

yched’s picture

Status: Needs review » Needs work

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())

Dave Reid’s picture

Isn't that what we're testing?

yched’s picture

Status: Needs work » Reviewed & tested by the community

Ooops, crosspost, my comment was for patch #4.

RTBC :-)

Dave Reid’s picture

Small change to the assertion messages, no functional change so leaving RTBC.

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks!

Committed/pushed to 8.x, moving to 7.x for backport.

Purencool’s picture

Assigned: Unassigned » Purencool
Purencool’s picture

Assigned: Purencool » Unassigned
willvincent’s picture

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.

webchick’s picture

Status: Patch (to be ported) » Needs review

Moving to 'needs review'.

Status: Needs review » Needs work

The last submitted patch, field_info_instances_fix_returns-1245332-14-7.x.p0.patch, failed testing.

rfay’s picture

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 -p1 with a standard git patch.

willvincent’s picture

Good call, though I don't believe it's possible to specify that -p1 flag with drush make

rfay’s picture

drush make has handled git-style patches for many months now.

willvincent’s picture

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. :)

rfay’s picture

Yes, git patches are just patch -p1 patches. 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.

willvincent’s picture

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.

willvincent’s picture

Status: Needs work » Needs review
Dave Reid’s picture

Re-uploading D7 patch only.

dimitriseng’s picture

I have tested #24 and I can confirm that it seems to resolve the issue, thank you!

Dave Reid’s picture

Feel free to mark this issue as 'reviewed and tested by the community' then so we can get this fixed in Drupal 7. :)

yched’s picture

Status: Needs review » Reviewed & tested by the community

yup, same as for D8

willvincent’s picture

Weird. Why did it pass when you uploaded it?

marcingy’s picture

Version: 7.x-dev » 8.x-dev

Bumping to d8 because it needs to go in there first

marcingy’s picture

Version: 8.x-dev » 7.x-dev

My bad

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x. Thanks!

Status: Fixed » Closed (fixed)

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

Dig1’s picture

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 :)

funature’s picture

it works for me too

drupalninja99’s picture

Did this ever make it to a stable release? I don't see a note anywhere

rfay’s picture

Issue tags: -Needs backport to D7

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...