Call to undefined method Drupal\message\Entity\Message::getFieldValue() in Drupal\social_activity\EmailTokenServices-

Created on 4 November 2024, 30 days ago

Problem/Motivation

this module has an undefined method : Call to undefined method Drupal\message\Entity\Message::getFieldValue() in Drupal\social_activity\EmailTokenServices->getRelatedObject

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

12.4

Component

Code (back-end)

Created by

πŸ‡ΊπŸ‡ΈUnited States dianacastillo Miami

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dianacastillo
  • πŸ‡ΊπŸ‡¦Ukraine v.koval

    Hi!
    Where do you have this error?
    Can you provide steps to reproduce this?
    Because, the Message entity should have the getFieldValue() 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.

  • πŸ‡ΊπŸ‡ΈUnited States dianacastillo Miami
Production build 0.71.5 2024