? constants.pl ? head.kpf ? patches ? test.php ? 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.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v retrieving revision 1.1 diff -u -F^[fc] -r1.1 field.api.php --- modules/field/field.api.php 7 Feb 2009 19:43:00 -0000 1.1 +++ modules/field/field.api.php 8 Feb 2009 23:00:13 -0000 @@ -1,5 +1,5 @@ array(), 'additions' => array()); + foreach (module_implements('field_attach_load') as $module) { + $function = $module . '_field_attach_load'; + $return = $function($obj_type, $queried_objects, $age, $loaded['fields']); + // We can't use array_merge_recursive() here because it will not + // preserve the numeric object ids. + foreach ($return['additions'] as $id => $fields) { + $loaded['additions'][$id] = $fields; + } + $loaded['fields'] = array_merge($loaded['fields'], $return['fields']); + } + + // The field storage engine loads the rest. + $additions = module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_load', $obj_type, $queried_objects, $age, $loaded['fields']); + foreach ($additions as $id => $obj_additions) { foreach ($obj_additions as $key => $value) { $queried_objects[$id]->$key = $value; } } + foreach ($loaded['additions'] as $id => $obj_additions) { + foreach ($obj_additions as $key => $value) { + $queried_objects[$id]->$key = $value; + $additions[$id][$key] = $value; + } + } // TODO D7 : to be consistent we might want to make hook_field_load() accept // multiple objects too. Which forbids going through _field_invoke(), but @@ -247,15 +271,6 @@ function _field_attach_load($obj_type, $ $additions[$id][$key] = $value; } - // Let other modules act on loading the object. - // TODO : this currently doesn't get cached (we cache $additions). - // This should either be called after we fetch from cache, or return an - // array of additions. - foreach (module_implements('field_attach_load') as $module) { - $function = $module . '_field_attach_load'; - $function($obj_type, $queried_objects[$id]); - } - // Cache the data. if ($cacheable) { $cid = "field:$obj_type:$id:$vid"; @@ -374,14 +389,19 @@ function _field_attach_presave($obj_type */ function _field_attach_insert($obj_type, &$object) { - // Let other modules act on inserting the object. + _field_invoke('insert', $obj_type, $object); + + // Let other modules act on inserting the object, accumulating saved + // fields along the way. + $saved = array(); foreach (module_implements('field_attach_insert') as $module) { $function = $module . '_field_attach_insert'; - $function($obj_type, $object); + $return = $function($obj_type, $object, $saved); + $saved = array_merge($saved, $return); } - _field_invoke('insert', $obj_type, $object); - module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_write', $obj_type, $object); + // Field storage module saves any remaining unsaved fields. + module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_write', $obj_type, $object, FALSE, $saved); list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object); if ($cacheable) { @@ -399,14 +419,19 @@ function _field_attach_insert($obj_type, */ function _field_attach_update($obj_type, &$object) { - // Let other modules act on updating the object. + _field_invoke('update', $obj_type, $object); + + // Let other modules act on updating the object, accumulating saved + // fields along the way. + $saved = array(); foreach (module_implements('field_attach_update') as $module) { $function = $module . '_field_attach_update'; - $function($output, $obj_type, $object); + $return = $function($obj_type, $object, $saved); + $saved = array_merge($saved, $return); } - _field_invoke('update', $obj_type, $object); - module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_write', $obj_type, $object, TRUE); + // Field storage module saves any remaining unsaved fields. + module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_write', $obj_type, $object, TRUE, $saved); list($id, $vid, $bundle, $cacheable) = field_attach_extract_ids($obj_type, $object); if ($cacheable) { Index: modules/field/field.autoload.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.autoload.inc,v retrieving revision 1.2 diff -u -F^[fc] -r1.2 field.autoload.inc --- modules/field/field.autoload.inc 8 Feb 2009 21:22:59 -0000 1.2 +++ modules/field/field.autoload.inc 8 Feb 2009 23:00:13 -0000 @@ -505,7 +505,9 @@ function field_info_bundle_entity($bundl * Return array of all field data, keyed by field name. * * @return - * An array of Field objects. + * An array of Field objects. Each Field object has an additional + * property, bundles, which is an array of all the bundles to which + * this field belongs. * * This function is an autoloader for _field_info_fields() in modules/field/field.info.inc. */ @@ -518,6 +520,11 @@ function field_info_fields() { * Return data about an individual field. * * @param $field_name + * The name of the field to retrieve. + * @return + * The named field object, or NULL. The Field object has an additional + * property, bundles, which is an array of all the bundles to which + * this field belongs. * * This function is an autoloader for _field_info_field() in modules/field/field.info.inc. */ Index: modules/field/field.crud.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v retrieving revision 1.3 diff -u -F^[fc] -r1.3 field.crud.inc --- modules/field/field.crud.inc 8 Feb 2009 21:22:59 -0000 1.3 +++ modules/field/field.crud.inc 8 Feb 2009 23:00:13 -0000 @@ -338,10 +338,11 @@ function field_create_instance($instance _field_write_instance($instance); - module_invoke_all('field_create_instance', $instance); - // Clear caches field_cache_clear(); + + module_invoke_all('field_create_instance', $instance); + return FALSE; } Index: modules/field/modules/field_sql_storage/field_sql_storage.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module,v retrieving revision 1.3 diff -u -F^[fc] -r1.3 field_sql_storage.module --- modules/field/modules/field_sql_storage/field_sql_storage.module 5 Feb 2009 03:42:57 -0000 1.3 +++ modules/field/modules/field_sql_storage/field_sql_storage.module 8 Feb 2009 23:00:13 -0000 @@ -1,5 +1,5 @@ $ids) { + if (isset($skip_fields[$field_name])) { + continue; + } + $field = field_info_field($field_name); $table = $load_current ? _field_sql_storage_tablename($field_name) : _field_sql_storage_revision_tablename($field_name); @@ -229,13 +236,17 @@ function field_sql_storage_field_storage return $additions; } -function field_sql_storage_field_storage_write($obj_type, $object, $update = FALSE) { +function field_sql_storage_field_storage_write($obj_type, $object, $update = FALSE, $skip_fields = array()) { list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object); $etid = _field_sql_storage_etid($obj_type); $instances = field_info_instances($bundle); foreach ($instances as $instance) { $field_name = $instance['field_name']; + if (isset($skip_fields[$field_name])) { + continue; + } + $table_name = _field_sql_storage_tablename($field_name); $revision_name = _field_sql_storage_revision_tablename($field_name); $field = field_read_field($field_name); Index: modules/simpletest/tests/field_test.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/field_test.module,v retrieving revision 1.2 diff -u -F^[fc] -r1.2 field_test.module --- modules/simpletest/tests/field_test.module 5 Feb 2009 03:42:58 -0000 1.2 +++ modules/simpletest/tests/field_test.module 8 Feb 2009 23:00:13 -0000 @@ -84,7 +84,7 @@ function field_test_fieldable_info() { } function field_test_create_bundle($bundle, $text) { - $bundles = variable_get('field_test_bundles', array('field_text_bundle' => 'Test Bundle')); + $bundles = variable_get('field_test_bundles', array('test_bundle' => 'Test Bundle')); $bundles += array($bundle => $text); variable_set('field_test_bundles', $bundles); @@ -92,7 +92,7 @@ function field_test_create_bundle($bundl } function field_test_rename_bundle($bundle_old, $bundle_new) { - $bundles = variable_get('field_test_bundles', array('field_text_bundle' => 'Test Bundle')); + $bundles = variable_get('field_test_bundles', array('test_bundle' => 'Test Bundle')); $bundles[$bundle_new] = $bundles[$bundle_old]; unset($bundles[$bundle_old]); variable_set('field_test_bundles', $bundles); @@ -101,7 +101,7 @@ function field_test_rename_bundle($bundl } function field_test_delete_bundle($bundle) { - $bundles = variable_get('field_test_bundles', array('field_text_bundle' => 'Test Bundle')); + $bundles = variable_get('field_test_bundles', array('test_bundle' => 'Test Bundle')); unset($bundles[$bundle]); variable_set('field_test_bundles', $bundles);