Testing fails (running locally, or on the bot):

FieldException: Attempt to create an instance of field color without an object type. in field_create_instance() (line 624 of /home/rfay/workspace/d7git/modules/field/field.crud.inc). Fatal error: Exception thrown without a stack frame in Unknown on line 0

Thanks, cyberswat

Comments

cyberswat’s picture

I'll take a look at this asap

rfay’s picture

rfay’s picture

Per cyberswat: tell rfay that if I were to guess about #755640 it is that the cardinality should not be on the $instance but should be on the $field … try removing it from the instance.

arpeggio’s picture

Try this patch (in line 65 of node_example.install just change the key from object_type to entity_type):

--- node_example.install   6 Apr 2010 18:25:47 -0000   1.3
+++ node_example.install   9 Apr 2010 07:19:21 -0000
@@ -62,7 +62,7 @@
   // Create all the instances for our fields.
   // http://api.drupal.org/api/function/field_create_instance/7
   foreach (node_example_installed_instances() as $instance) {
-    $instance['object_type'] = 'node';
+    $instance['entity_type'] = 'node';
     $instance['bundle'] = $node_example['type'];
     field_create_instance($instance);
   }
cyberswat’s picture

StatusFileSize
new793 bytes

Let's see if that makes it through testing

cyberswat’s picture

Status: Active » Needs review
rfay’s picture

Status: Needs review » Fixed

I ran it locally and it worked fine, so committed to HEAD: http://drupal.org/cvs?commit=352596

Now I'll see if I can convince the bot to test again.

Thanks!

Marking (hopefully) fixed.

rfay’s picture

Yeah, that did it: http://qa.drupal.org/pifr/test/26934 !!!!

Thanks, all.
-Randy

cyberswat’s picture

@arpeggio Thanks a bunch for finding that!

arpeggio’s picture

You're welcome. Its my pleasure to help Drupal community.

scallopedllama’s picture

Ummm... I still get that error when trying to install the module with the latest version.

FieldException: Attempt to create an instance of field color without an object type. in field_create_instance() (line 624 of /.../modules/field/field.crud.inc).

EDIT: In fact, reverting that change (changing $instance['entity_type'] back to $instance['object_type']) makes that error go away for me.

rfay’s picture

@scallopedllama I just enabled the module and exercised the node-add without trouble.

You may want to uninstall, remove the files, get the latest dev.

Or it could be dependent on your environment or something. In that case, after doing the above, please update!

scallopedllama’s picture

I guess my problems were coming from the fact I wasn't using the latest dev version of Drupal 7, I had an alpha installed. After upgrading to the latest dev, the error went away.

Status: Fixed » Closed (fixed)

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

rfay’s picture

Status: Closed (fixed) » Needs work

This is a new break, but the parties that matter are here.

We get this fatal now when running the tests:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=31&op=do StatusText: Service unavailable (with message) ResponseText: FieldException: Attempt to update an instance of a nonexistent field. in field_update_instance() (line 686 of /home/rfay/workspace/d7git/modules/field/field.crud.inc). Fatal error: Exception thrown without a stack frame in Unknown on line 0
rfay’s picture

Status: Needs work » Needs review
StatusFileSize
new8.98 KB

OK, here's what I did.

  • Had to do a Drupal core reinstall.
  • Changed the hook_node_info() 'base' to 'node_example' ('base' => 'node_example',) It used to be 'base' => 'node_content'
  • Added the explicit body definition in the install file (example: blog.module)
  • Since the commit of #553306: Make nodes have no body field by default. Remove deprecated APIs for body field I was unable to get the node-definition-in-install-file process to work any more, so I moved it to hook_node_info().
  • Without the .install way of doing it I had to define hook_form() (thanks jhodgdon and mikey_p)
  • Added a bunch of docs.
  • There are a couple of random things attached to this patch that were tiny changes in simpletest_example.

I have no objection to finding a way back to the "do it all in the install file" technique, but couldn't find the way past the fatal error without doing this.

Let's get it back to the best practice if this is not it.

Thanks!
-Randy

rfay’s picture

Committed to HEAD: http://drupal.org/cvs?commit=363812

I'm going to leave this open a while hoping for review from those of you in the know.

Status: Needs review » Needs work

(Never mind this... the patch got committed before testing of this patch, so it didn't apply)

The last submitted patch, examples.node_example_broken_755640_17.patch, failed testing.

webchick’s picture

OMG SYSTEM MESSAGE HAS BECOME SELF AWARE! ;)

Thanks for posting this, randy. I'm a bit confused, because I never knew of a way to create a node type in a .install file before? hook_node_info(), hook_form(), etc. are the standard way to do this. Hmmm...

catch’s picture

book.install uses node_type_save() in hook_install(), why is that not working for you?

rfay’s picture

@webchick: The discussion about this approach was in #706738: Update the node_example for Drupal 7 and in #508342: D7 Node example demonstrating fields and finally in #763724: Add a D6-style Node Example to the Node Example module.

@catch: I'm really interested in why also. I would also be interested in you weighing in on the best practices view of the two ways of doing this.

catch’s picture

@rfay: I hate nook_node_type(), and all the stupid hook_$foo() hooks which aren't really hooks, and nearly tried to get rid of core usage of them in that patch because of the weird node_types_rebuild() stuff before chickening out. Not sure if that counts as best practices though ;)

rfay’s picture

Status: Needs work » Fixed

Marking this fixed. If anybody thinks we should be demonstrating a better approach, please say so!

Status: Fixed » Closed (fixed)

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

chx’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new9.94 KB

I reverted #17 and made node_example install again by adding a body field myself. You tried to update an instance that does not exist. The test says: Node example 18 passes, 0 fails, 0 exceptions, and 5 debug messages

Literally, the only change is adding node_add_body_field($content_type); To make things more interesting I made a mistake by adding it before the content_type_save and it still worked! Moral of the story: field crud does not give a hoot whether a bundle exists or not, it will happily instance a field to a nonexisting bundle.

ilo’s picture

Status: Needs review » Reviewed & tested by the community

I love the way this module is built with D7 API, and explanations are clear enough. After manual and simpletest testing without visible errors I'll mark as rtbc.

rfay’s picture

I would say if you like it and chx likes it, commit it.

rfay’s picture

Status: Reviewed & tested by the community » Needs work

Unfortunately, we lost a lot of improvements to the code that have gone on in other issues with this one, so this patch needs to be pared down to just the things that chx wants. I sure appreciate your involvement here, chx.

+++ node_example/node_example.install	19 Sep 2010 16:37:29 -0000
@@ -3,44 +3,53 @@
- * Install file for Node Example module.
- *
- * The definition of the fields for the module is here, although
- * node_example_node_info() provides the actual content type definition.
- *
- * See @link http://drupal.org/node/707832 Field API Tutorial @endlink
- *
- * See @link http://drupal.org/node/443536 Field API Handbook Page @endlink
- *
- * See @link field Field API documentation @endlink

In at least two places documentation was removed that need not be removed.

+++ node_example/node_example.install	19 Sep 2010 16:37:29 -0000
@@ -48,26 +57,27 @@ function node_example_install() {
-  foreach (_node_example_installed_fields() as $field) {
+  foreach (node_example_installed_fields() as $field) {

Deliberate attempts to demonstrate that functions were private were removed.

Powered by Dreditor.

ilo’s picture

rfay, I'm going to leave this one for you. Everything about comments and deliberate purposes makes me run.. I'll focus on other issues for now.

rfay’s picture

Assigned: Unassigned » rfay

Yes, you're right, and I should finish this one.

rfay’s picture

Status: Needs work » Needs review
StatusFileSize
new22.64 KB

OK, I took chx's patch and made cosmetic changes, keeping the new comments and such that had been added in the meantime. It passes the tests and I think it's good to go. @chx, would appreciate you taking a look. Thanks so much for your investment in this issue. Thanks for pursuing this ilo! We sure want Examples to reflect what the developers consider to be best practices.

Status: Needs review » Needs work

The last submitted patch, examples.node_example_508342_32.patch, failed testing.

rfay’s picture

Status: Needs work » Needs review
StatusFileSize
new5.48 KB

Wow, I'm baffled what I did with that last patch. Here's another try.

chx’s picture

Status: Needs review » Needs work

+ // Define the node type. This is similar to hook_node_info() in Drupal 6

nah. it's just a node type. node_type_save exists since Drupal 5 and has not much to do w hook_node_info, really.

rfay’s picture

Status: Needs work » Fixed

Committed with chx #35: http://drupal.org/cvs?commit=436532

Thanks so much for your involvement here, chx. It means the world to have quality feedback on these things.

Status: Fixed » Closed (fixed)

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