- Issue created by @dianacastillo
- πΊπ¦Ukraine v.koval
Hi!
Where do you have this error?
Can you provide steps to reproduce this?
Because, theMessage
entity should have thegetFieldValue()
method - πΊπΈUnited States dianacastillo Miami
i get this as soon as i load the site which is 10.2 . maybe the message module is not the right version ?
- πΊπΈUnited States dianacastillo Miami
according to this , getFieldValue no longer exists in core https://www.drupal.org/project/drupal/issues/3247635 β
- πΊπΈUnited States dianacastillo Miami
if i add this code to the core contententitybase.php it works :
/**
* Gets the value of a specific property of a field.
*
* Only the first delta can be accessed with this method.
*
* @param string $field_name
* The name of the field.
* @param string $property
* The field property, "value" for many field types.
*
* @return mixed
*/
public function getFieldValue($field_name, $property) {
// Attempt to get the value from the values directly if the field is not
// initialized yet.
if (!isset($this->fields[$field_name])) {
$field_values = NULL;
if (isset($this->values[$field_name][$this->activeLangcode])) {
$field_values = $this->values[$field_name][$this->activeLangcode];
}
elseif (isset($this->values[$field_name][LanguageInterface::LANGCODE_DEFAULT])) {
$field_values = $this->values[$field_name][LanguageInterface::LANGCODE_DEFAULT];
}if ($field_values !== NULL) {
// If there are field values, try to get the property value.
// Configurable/Multi-value fields are stored differently, try accessing
// with delta and property first, then without delta and last, if the
// value is a scalar, just return that.
if (isset($field_values[0][$property]) && is_array($field_values[0])) {
return $field_values[0][$property];
}
elseif (isset($field_values[$property]) && is_array($field_values)) {
return $field_values[$property];
}
elseif (!is_array($field_values)) {
return $field_values;
}
}
}// Fall back to access the property through the field object.
return $this->get($field_name)->$property;
}
}
/code> - π³π±Netherlands robertragas
Hello dianacastillo,
We are trying to remove the getFieldValue from our codebase. I wonder though how your composer.json file looks like.
If you look at the codebase for version 12.4.5 which you can see here https://git.drupalcode.org/project/social/-/blob/12.4.5/composer.json?re... you can see we have applied a patch to drupal/core that add the getFieldValue method.
"Optimize getCommentedEntity()": "https://www.drupal.org/files/issues/2018-12-28/2580551-72.patch",
Could it be that in your codebase this patch is not added or not applying anymore?
- πΊπΈUnited States dianacastillo Miami
hi thank you, i installed the code without composer since its a multi site.