backdrop-contrib / entity_plus

This module wraps in a variety of additional entity-related functionality from various sources. Partial port of D7 Entity API.
https://backdropcms.org/project/entity_plus
GNU General Public License v2.0
3 stars 11 forks source link

Error about required data type #158

Closed robertgarrigos closed 1 year ago

robertgarrigos commented 1 year ago

With lates version 1.x-1.0.18, I'm having this error when saving a custom node type:

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. a EntityBackdropWrapper->set() (línia 761 de /app/www/modules/entity_plus/includes/entity_plus.wrapper.inc).

I will try to track it down, but just leaving this issue here for now.

argiepiano commented 1 year ago

Thanks, @robertgarrigos. This is a legitimate error. It happens when a function tries to assign the wrong type of value to an entity field via a metadata wrapper, for example, assigning an array to a field that only accepts a string (via metadata wrapper's set). Rather than focusing on debugging Entity Plus, please try to track down the error to see which module is producing it. In my experience, 100% of the time this is due to an error beyond E+.

robertgarrigos commented 1 year ago

Thanks, @argiepiano. For now, I cant tell you that this happens only with php 8.x. No problem with php 7.4

argiepiano commented 1 year ago

Thanks. That's an important clue. Would you be willing to do some debugging to find out which metadata property is throwing this in your site?

argiepiano commented 1 year ago

The easiest way to debug this is to insert the following in entity_plus.wrapper.inc, line 760

    if (!$this->validate($value)) {
      dpm($value, 'value'); dpm($this->getPropertyInfo(), 'propertyInfo');
      throw new EntityMetadataWrapperException('Invalid data value given. Be sure it matches the required data type and format.');
    }

Notice the added dpms. Then paste the output here.

robertgarrigos commented 1 year ago

Sorry, @argiepiano, I cannot reproduce the error. I had other errors, which provably affected this one, as I fixed them and made this one disappear.