Hi,

I found a specific "bug" on Entity class (file entity/includes/entity.inc).
Well in the class we have property "$wrapper".
And if we declared a field with the same name on hook_schema() we will get the next error after try create an entity:

Error: Cannot access protected property Entity ::$wrapper in entity_form_submit_build_entity() (line 8291 of ../includes/common.inc).

Why it happens?

In the Entity class we have the next constructor:

  /**
   * {@inheritdoc}
   */
  public function __construct(array $values = array(), $entityType = NULL) {
    if (empty($entityType)) {
      throw new Exception('Cannot create an instance of Entity without a specified entity type.');
    }
    $this->entityType = $entityType;
    $this->setUp();
    // Set initial values.
    foreach ($values as $key => $value) {
      $this->$key = $value;
    }
  }

Please have a look to "foreach" loop.
And how you can see this code set new property for the object.
So if you use field with name "wrapper" you will get an error like "Error: Cannot access protected property Entity ..."

For to avoid this misunderstanding I think we just need rename this property from "$wrapper" to "$entityWrapper".
I guess this name will more clear.

Thanks

Comments

slivorezka created an issue. See original summary.

Chris Matthews’s picture

Version: 7.x-1.8 » 7.x-1.x-dev
Category: Bug report » Support request
Issue tags: -wrapper