Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
This patch replaces $object with $entity, $obj_type with $entity_type and $objects with $entities. This does not change any API while it makes field API a lot more grokkable.
Comment | File | Size | Author |
---|---|---|---|
#43 | 707724-messages.patch | 1.63 KB | TR |
#38 | field_object_entity_replace-707724-38.patch | 853 bytes | yched |
#31 | field_object_entity_replace-707724-31.patch | 71.86 KB | yched |
#30 | field_object_entity_replace-707724-30.patch | 57.7 KB | yched |
#24 | sed_more.patch | 57.63 KB | chx |
Comments
Comment #1
yched CreditAttribution: yched commentedHah, an heroic soul rolled a patch :-). Be forever blessed.
Big big +1, and I'd advocate committing ASAP and fixing possible remains later, because this patch will be HELL to reroll.
It would really need a bot seal, though...
Comment #2
Frando CreditAttribution: Frando commentedFinally! Big huge +1 from me too. I wanted to write this ever since entity API was committed but never got around to do it. This will avoid some huge DX WTFs in D7.
Yes, once tests pass, let's get it in ASAP.
Comment #3
yched CreditAttribution: yched commentedI guess we're stuck with the API facing occurrences, though :
- {field_config_instance}.object_type schema column
- 'object keys' in hook_entity_info()
- 'object_types' in $field definitions
- 'object_type' in $instance definitions
- 'obj_type' and 'object' in hook_field_attach_view_alter()'s $context param
:-/
Comment #5
chx CreditAttribution: chx commentedLet's see this.
Edit: I rolled using:
Edit2: the previous patch missed /g . My bad.
Comment #6
yched CreditAttribution: yched commentedIf the bot is happy, let's commit this before it breaks.
Comment #7
webchickIt broke. :(
Great patch, though.
Comment #8
chx CreditAttribution: chx commentedThe bot can jank back to CNW if it broke. I reran the script.
Comment #9
chx CreditAttribution: chx commentedOpsie that was the old patch.
Comment #11
chx CreditAttribution: chx commentedSniff, sniff. The bzr mirror is behind by about an hour.
Comment #13
chx CreditAttribution: chx commentedComment #14
webchickAwesome, thanks.
Committed to HEAD.
Comment #15
yched CreditAttribution: yched commentedW00t.
And here's the remainder - mostly comments and PHPdocs. That one was manual, folks :-p. Never. Again.
Comment #16
Pasquallenice patch
totally off topic: I noticed that some simpletest messages are translated and some messages are not. Can someone tell me the issue number? I guess we do not need to translated those, same as we do not translate schema descriptions. It is just an extra work for translators without rational benefits.
Comment #17
webchickMy goodness! You poor thing. :(
Committed to HEAD, while it's still fresh. :)
Comment #18
Pasqualleit's still not complete
found one more which can be fixed without breaking the API:
http://api.drupal.org/api/function/field_ui_existing_field_options/7
***************************************************
fixing these would break the API:
(search obj_type)
http://api.drupal.org/api/function/hook_field_attach_view_alter/7
http://api.drupal.org/api/function/field_view_field/7
http://api.drupal.org/api/function/hook_field_attach_preprocess_alter/7
http://api.drupal.org/api/function/field_attach_view/7
http://api.drupal.org/api/function/field_attach_preprocess/7
http://api.drupal.org/api/function/field_create_instance/7
http://api.drupal.org/api/function/locale_field_attach_view_alter/7
http://api.drupal.org/api/function/locale_field_fallback_view/7
(search object_type)
http://api.drupal.org/api/function/field_format/7
http://api.drupal.org/api/function/hook_field_widget_form/7
http://api.drupal.org/api/function/_field_invoke/7
http://api.drupal.org/api/function/field_attach_load/7
http://api.drupal.org/api/function/field_attach_view/7
http://api.drupal.org/api/function/field_attach_rename_bundle/7
field.crud.inc
http://api.drupal.org/api/function/field_default_view/7
http://api.drupal.org/api/function/field_default_form/7
http://api.drupal.org/api/function/field_multiple_value_form/7
http://api.drupal.org/api/function/_field_info_collate_fields/7
http://api.drupal.org/api/function/_field_info_prepare_instance/7
field_sql_storage.module
field_sql_storage.test
field.test
http://api.drupal.org/api/function/field_ui_inactive_instances/7
... (and many more)
***************************************************
these are 3 different cases:
context['obj_type'] : function parameters stored in array
#object_type : render element
instance['object_type'] : db column field_config_instance.object_type
so it is still confusing..
Comment #19
PasqualleAs I see we already broke the field API since alpha1 with #641670: Move $form['#field'] meta information into $form_state so we might do it again to fix this issue once and for all..
Comment #20
moshe weitzman CreditAttribution: moshe weitzman commentedComment #21
yched CreditAttribution: yched commentedre #18 : yup, that's the remaining ocurrences I pointed in #3. Part of the public API, so changing these are API changes.
Agreed on RTBC for the fix in the patch.
Comment #22
chx CreditAttribution: chx commentedPasqualle and all -- yes I am (painfully) aware of those. We can't fix everything in D7 IMO -- but let's see what the core committers are going to say.
Comment #23
Dries CreditAttribution: Dries commentedCommitted the patch in #18.
Personally, I don't think it makes sense to leave things in an intermediate state -- it feels like that would only add to the confusion.
Comment #24
chx CreditAttribution: chx commentedAs Dries asked I ran more sed, this time nuking all occurences of obj_type and object_type and changed 'object' => 'entity' and fixed the new presave functions by hand.
Comment #26
KarenS CreditAttribution: KarenS commentedStill badly needed. It is totally confusing to see all the remaining mixed use of 'object_type' and 'object' vs 'entity_type' and 'entity' throughout the code.
Comment #27
aspilicious CreditAttribution: aspilicious commented#24: sed_more.patch queued for re-testing.
Comment #28
aspilicious CreditAttribution: aspilicious commenteddamn didn't wonna retest..
Well... Ok then...
Comment #30
yched CreditAttribution: yched commentedRerolled. You don't scare me, bot.
Comment #31
yched CreditAttribution: yched commentedRather try this one - additionally replaces 'object keys' -> 'entity keys' in hook_entity_info().
Comment #32
yched CreditAttribution: yched commentedW00t !.
This will break anytime. If we still want to do this, now looks like a good time.
Comment #33
webchickHm. I guess Dries says in #23 that the API breaking train is okay, in favour of consistency in this part of the code.
Committed to HEAD, but are we about done here? It's awfully late for any more of these kinds of changes.
Comment #34
KarenS CreditAttribution: KarenS commentedYeah but this one was a huge WTF for anyone trying to port their code (which is where I ran into it). Do we have objects or entities? Oh no, in this place it is an object, in that place it is an entity. We needed to get this in.
Comment #35
yched CreditAttribution: yched commentedThks Angie.
Not really related to the 'object' / 'entity' stuff, but I think the last naming WTF is the 'cacheable' property in hook_entity_info(), whose meaning is ambiguous since the entity API landed. Been discussed for months but no-one set to it so far. Couldn't find an existing issue, created #754686: Rename 'cacheable' property in hook_entity_info()
Should the changes that got committed here be mentioned on http://drupal.org/update/modules/6/7 ? Or somewhere else ?
Comment #36
KarenS CreditAttribution: KarenS commentedAre we doing updates from prior versions now? If so, we have a db table change that needs an update. The 'field_config_instance' table changed the column name from 'object_type' to 'entity_type'. I think that is the only db change, it's the only one I've run into.
Comment #37
yched CreditAttribution: yched commentedAs a summary of the API changes:
- db table field_config_instance:
'object_type' column renamed to 'entity_type'
- hook_entity_info():
'object keys' entry renamed to 'entity keys'
- $field definitions:
$field['object_types'] entry renamed to $field['entity_types']
- $instance definitions:
$instance['object_type'] entry renamed to $instance['entity_type']
- hook_field_attach_view_alter(), $context parameter:
$context['obj_type'] and $context['object'] entries renamed to $context['entity_type'] and $context['entity']
Comment #38
yched CreditAttribution: yched commentedFollowup - one occurrence slipped through.
Comment #39
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD, however, this suggests that our tests aren't 100% yet.
Comment #40
yched CreditAttribution: yched commentedre Dries #39 : Well, this specific test happens to be a little conservative, and the second clause usually catches the case at hand, so this omission had no actual effect.
Comment #41
JohnAlbinFor those people getting PHP notices/failures because of the DB change introduced with this patch (what Karen mentions in #36 above), you can use the following query to fix it in MySQL:
Also, see #763636: Notice: Undefined index: view modes in _field_info_prepare_instance()
Comment #43
TR CreditAttribution: TR commentedI found two places where "object" is still used instead of "entity" in user-facing exception messages. Patch doesn't affect the API, just the content of the message strings.
Comment #44
yched CreditAttribution: yched commentedRight.
Comment #45
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.