Download & Extend

Warning when all bundles removed from an entity

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

Project:Drupal Commerce» Drupal core
Version:7.x-1.x-dev» 8.x-dev
Component:Commerce» entity system
Status:active» needs review

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

AttachmentSizeStatusTest resultOperations
drupal.field_info_instances_warning.patch556 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 33,632 pass(es).View details

#2

Status:needs review» reviewed & tested by the community

Look sensible as far as I can see.

#3

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.

#4

Status:needs work» needs review
Issue tags:-Needs tests

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.

AttachmentSizeStatusTest resultOperations
1245332-field-info-intances-fix-returns.patch2.88 KBIdleFAILED: [[SimpleTest]]: [MySQL] 34,577 pass(es), 2 fail(s), and 0 exception(s).View details

#5

Status:needs review» needs work

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

#6

Status:needs work» needs review

Revised patch, passes tests.

AttachmentSizeStatusTest resultOperations
1245332-field-info-intances-fix-returns.patch3.65 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,590 pass(es).View details

#7

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

#8

Isn't that what we're testing?

#9

Status:needs work» reviewed & tested by the community

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

RTBC :-)

#10

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

AttachmentSizeStatusTest resultOperations
1245332-field-info-intances-fix-returns.patch3.63 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,585 pass(es).View details

#11

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.

#12

Assigned to:Anonymous» purencool

#13

Assigned to:purencool» Anonymous

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

AttachmentSizeStatusTest resultOperations
field_info_instances_fix_returns-1245332-14-7.x.patch3.6 KBIdleFAILED: [[SimpleTest]]: [MySQL] Repository checkout: failed to checkout from [git://git.drupal.org/project/drupal.git].View details
field_info_instances_fix_returns-1245332-14-7.x.p0.patch3.51 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch field_info_instances_fix_returns-1245332-14-7.x.p0.patch. Unable to apply patch. See the log in the details link for more information.View details

#15

Status:patch (to be ported)» needs review

Moving to 'needs review'.

#16

Status:needs review» needs work

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

#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

Status:needs work» needs review

#14: field_info_instances_fix_returns-1245332-14-7.x.patch queued for re-testing.

#24

Re-uploading D7 patch only.

AttachmentSizeStatusTest resultOperations
field_info_instances_fix_returns-1245332-14-7.x.patch3.6 KBIdlePASSED: [[SimpleTest]]: [MySQL] 38,324 pass(es).View details

#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

Status:needs review» reviewed & tested by the community

yup, same as for D8

#28

Weird. Why did it pass when you uploaded it?

#29

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

Bumping to d8 because it needs to go in there first

#30

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

My bad

#31

Status:reviewed & tested by the community» fixed

Committed and pushed to 7.x. Thanks!

#32

Status:fixed» closed (fixed)

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

nobody click here