When creating a file, the following code in entity_make_entity_local() unsets the file's fid property.

    // Fetch the local ID by its UUID.
    $ids = entity_get_id_by_uuid($entity_type, array($entity->{$uuid_key}));
    $id = reset($ids);
    // Set the correct local ID.
    if (empty($id)) {
      unset($entity->{$id_key});
      $entity->is_new = TRUE;
    }
    else {
      $entity->{$id_key} = $id;
      $entity->is_new = FALSE;
    }

When file_entity_access() is called during the create process, it checks the fid property. Since it no longer exists on the file object, we get the following PHP notice:
Notice: Undefined property: stdClass::$fid in file_entity_access() (line 1616 of /var/www/test/htdocs/sites/all/modules/contrib/file_entity/file_entity.module).

Since uuid.entity.inc's entity_make_entity_local() is manipulating the structure of a file_entity object (removing fid property), I decided to make this a uuid issue instead of a file_entity issue.

I'm thinking this is a simple fix by added fid = null to the entity in uuid.core.inc's file_entity_uuid_presave().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dkingofpa’s picture

Assigned: dkingofpa » Unassigned
Status: Active » Needs review
FileSize
1022 bytes

Patch attached.

  • skwashd committed 1251856 on 7.x-1.x
    Issue #2300301 #2236497 by skwashd: Fix formatting
    
  • skwashd committed 598e749 on 7.x-1.x authored by dkingofpa
    Issue #2300301 by dkingofpa: Fix undefined property notice in stdClass...
skwashd’s picture

Status: Needs review » Fixed

Thanks for the patch. I've committed it.

Status: Fixed » Closed (fixed)

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