Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
i am using a "geofield field type" with the "from another field widget" from the geocoder modul ( https://drupal.org/project/geocoder ) in one of my bookable unit types from the rooms module to gecode from an address field. First, everything seemed to work fine. But if i add a another bookable unit i get this error:
EntityMalformedException: Missing bundle property on entity of type rooms_unit. in entity_extract_ids() (line 7693 of /var/www/ua-repo/includes/common.inc).
Drupal 7.23
Commerce 7.x-1.8
Rooms 7.x-1.0
Comment | File | Size | Author |
---|---|---|---|
#5 | rooms-entity-original-2143515-5.patch | 932 bytes | jwilson3 |
Comments
Comment #1
ronald_istos CreditAttribution: ronald_istos commentedComment #2
AdamPS CreditAttribution: AdamPS commentedI can reproduce this error message reliably. I can't say for sure if it's the same bug as the OP, but it's the exact same message, so I thought worth re-opening the issue rather than creating a new one.
In my case there was no geocoder module. I have a standard Rooms install with not much else added.
- Rooms 7.x-1.3
- Drupal core 7.31
Scenario
- Create a unit type and a unit
- Create a booking
- Delete the unit that the booking uses: works fine, no warning that it was in use
- At this point the booking has a blank value for "unit" in the list of bookings
- Try to edit the booking (admin/rooms/bookings/booking/NNNNN/edit)
Expected behaviour
- Perhaps should disallow deleting the room?
- Should be able to edit the booking. In particular might want to assign a unit!
Comment #3
jwilson3I'm also able to repeat this error while attempting to convert the Waterbed Rooms feature by @enzo to remove the dependency on the rooms_node module, by adding the fields directly to the unit. There are two geo fields I've added to the rooms bookable unit: one is field_address and one is field_address_autocomplete. The field_address is configured to pull the value "from another field widget" (the autocomplete field). When creating the first unit, I get the same error as OP. I wasn't able to take this any further, and not really sure how to go about debugging this.
Steps to reproduce:
Comment #4
jwilson3I've tracked this down to the following lines of code in the geocoder.widget.inc:
the field_get_items() function expects the second parameter to be an actual entity object, but in this case $entity->original is set to the value TRUE.
I'm currently trying to figure out where $entity->original is being incorrectly set to TRUE in the codebase. This value should either be the unchanged entity object, or FALSE if the entity cannot be loaded, but never "TRUE". Weird.
Comment #5
jwilson3@Ronald:
I've tracked this issue down to the
RoomsUnitController::create()
method, which incorrectly sets a default value for the 'original' member to TRUE. This was introduced by http://cgit.drupalcode.org/rooms/commit/?id=b4fe0ea1.Coincidentally,
RoomsUnitController::create()
also has the same issue, introduced by http://cgit.drupalcode.org/rooms/commit/?id=5ba66263.Removing the lines does fix this error... so here is a patch.
As for why these lines were introduced, I don't know, so it would be good for @Ronald's input on this, to see if it makes sense.
From reading through the entity module codebase, it looks like the unwritten API for the $entity->original field is that it should only be populated when saving new data to an existing entity that already has a primary key, and it should be populated with a copy of the original entity object, using
entity_load_unchanged
. Otherwise it should be FALSE. it should never be TRUE.Comment #6
jwilson3Comment #7
plopescThank you @jwilson3. Committed.