- πΊπΈUnited States tr Cascadia
The commit in #4 was immediately reverted by commit df19319cd23fc816 without that revert being mentioned here, and without discussion, and without an issue for the reversion.
As a result, the problem pointed out by the original poster still exists today, more than 5 years later. And the problem is very clear. In the existing code we have:
public function getVoteSummary(ContentEntityInterface $vote) { $results = $this->getResults($vote); $field_name = $vote->field_name->value;
This is one of several parts of the code that make huge assumptions. Specifically, "field_name", as used here, does not do anything and does not work. And the intent of this last line of code is suspect - why is a variable named $field_name being set to the value of a field named "field_name" ? First, there is no field named "field_name". All we know about $vote is that it is a generic ContentEntityInterface - we don't even know that the entity is fieldable. And even if that generic entity holds a vote, we don't know the name of the field where that vote is store. But it's certainly NOT named "field_name". Second, if the variable is to hold a value, it should be named $field_value or something like that - what is the purpose of this line?
In short, this is still very much a problem. We absolutely need to look into all the uses of "$entity->field_name" in this module because none of them make any sense. I suspect these are a legacy of how the D7 version of this module worked.
And this also underscores the need for TEST CASES. This getVoteSummary() method, for example, should have a simple test case to demonstrate that it returns the expected result - it clearly doesn't.