Fixes/improved docs for VoteManager

Created on 22 July 2021, almost 4 years ago
Updated 2 September 2024, 8 months ago

Problem/Motivation

Drupal-check noticed some issues with VoteManager::addVote, and on further inspection there were more issues to address. Namely:
- $rating is assumed to be an integer but not checked.
- $rating is checked for >100 but not <0
- A type-hint on the voteStorage->create call assists drupal-check (etc) validate the function calls
- The function-docs on addVote were inadequate

Also:
- deleteVote is stubbed out without explanation, which seems odd. Inserted TODO to explain why.
- Exceptions thrown by getVoteTypes can be avoided by returning the empty list.
- Exceptions thrown by __construct should be documented.

Proposed resolution

Fixes for the above issues are included in the patch.

User interface changes

None.

API changes

The accepted type for the $vote_type parameter has been narrowed to 'string', which it should in all cases be anyway.
The accepted type for $rating is still 'mixed' but the @param now notes 'string' is accepted as well as 'int', and the conversion is explicitly managed.

Data model changes

None

πŸ“Œ Task
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom rivimey

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024