? FIELD-TO-COLUMN-PARTIAL.patch ? Makefile ? constants.pl ? d6-50-nodes.sql.gz ? d7-50-nodes-new.sql.gz ? d7-50-nodes.sql.gz ? head.kpf ? patches ? modules/field/field.cron.inc ? modules/field/modules/combo ? scripts/OLD-generate-autoload.pl ? scripts/generate-autoload.pl ? sites/all/cck ? sites/all/modules/devel ? sites/all/modules/pbs ? sites/all/modules/taint ? sites/default/files ? sites/default/settings.php Index: modules/field/field.crud.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v retrieving revision 1.16 diff -u -F^[fc] -r1.16 field.crud.inc --- modules/field/field.crud.inc 24 Jun 2009 18:16:38 -0000 1.16 +++ modules/field/field.crud.inc 2 Jul 2009 14:46:31 -0000 @@ -273,6 +273,9 @@ function field_create_field($field) { // Clear caches field_cache_clear(TRUE); + // Invoke external hooks after the cache is cleared for API consistency. + module_invoke_all('field_create_field', $field); + return $field; } Index: modules/field/field.test =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.test,v retrieving revision 1.28 diff -u -F^[fc] -r1.28 field.test --- modules/field/field.test 24 Jun 2009 18:16:38 -0000 1.28 +++ modules/field/field.test 2 Jul 2009 14:46:32 -0000 @@ -1320,8 +1320,10 @@ class FieldCrudTestCase extends DrupalWe 'field_name' => 'field_2', 'type' => 'test_field', ); + field_test_memorize(); $field_definition = field_create_field($field_definition); - + $mem = field_test_memorize(); + $this->assertIdentical($mem['field_test_field_create_field'][0][0], $field_definition, 'hook_field_create_field() called with correct arguments.'); $field = field_read_field($field_definition['field_name']); // Ensure that basic properties are preserved. Index: modules/simpletest/tests/field_test.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/field_test.module,v retrieving revision 1.9 diff -u -F^[fc] -r1.9 field_test.module --- modules/simpletest/tests/field_test.module 27 May 2009 18:34:00 -0000 1.9 +++ modules/simpletest/tests/field_test.module 2 Jul 2009 14:46:32 -0000 @@ -366,6 +366,68 @@ function field_test_field_schema($field) } /** + * Store and retrieve keyed data for later verification by unit tests. + * + * This function is a simple in-memory key-value store with the + * distinction that it stores all values for a given key instead of + * just the most recently set value. field_test module hooks call + * this function to record their arguments, keyed by hook name. The + * unit tests later call this function to verify that the correct + * hooks were called and were passed the correct arguments. + * + * This function ignores all calls until the first time it is called + * with $key of NULL. Each time it is called with $key of NULL, it + * erases all previously stored data from its internal cache, but also + * returns the previously stored data to the caller. A typical usage + * scenario is: + * + * @code + * // calls to field_test_memorize() here are ignored + * + * // turn on memorization + * field_test_memorize(); + * + * // call some Field API functions that invoke field_test hooks + * $field = field_create_field(...); + * + * // retrieve and reset the memorized hook call data + * $mem = field_test_memorize(); + * + * // make sure hook_field_create_field() is invoked correctly + * assertEqual(count($mem['field_test_field_create_field']), 1); + * assertEqual($mem['field_test_field_create_field'][0], array($field)); + * @endcode + * + * @param $key + * The key under which to store to $value, or NULL as described above. + * @param $value + * A value to store for $key. + * @return + * An array mapping each $key to an array of each $value passed in + * for that key. + */ +function field_test_memorize($key = NULL, $value = NULL) { + $memorize =& drupal_static(__FUNCTION__, NULL); + + if (is_null($key)) { + $ret = $memorize; + $memorize = array(); + return $ret; + } + if (is_array($memorize)) { + $memorize[$key][] = $value; + } +} + +/** + * Memorize calls to hook_field_create_field(). + */ +function field_test_field_create_field($field) { + $args = func_get_args(); + field_test_memorize(__FUNCTION__, $args); +} + +/** * Implement hook_field_validate(). * * Possible error codes: