Automattic / Automattic/crowdsignal-plugin
Error updating ratings
- Dominant language
- PHP
- Stars
- 15
- Forks
- 11
- Avg merge
- 14m
- Merged PRs (30d)
- 1
Description
The `update_rating` function throws a warning when reaching line 4522:
https://github.com/Automattic/crowdsignal-plugin/blob/6afe835d7625758287c70e4410e78e88640b97f4/polldaddy.php#L4522
The variable is declared as `null` at the beginning of the function, around line 4500:
```php
function update_rating() {
$rating_type = 0;
$rating_id = 0;
$new_rating_id = 0;
$type = 'post';
$set = null; // <---- here
```
and never assigned a value until line 4522 is reached. As PHP allows, a `null` value will be converted to a `default object` so the function should not fail. However, the warning is thrown and if the user has enabled warnings it will be shown on the screen as described on the forum post.
The error was reported on the forums:
https://wordpress.org/support/topic/errors-when-making-changes/

Contributor guide
Research direction
Start in polldaddy.php at the update_rating() function around lines 4500 and 4522, and inspect how $set is used before the warning occurs. Reproduce the forum-reported update flow with warnings enabled; done means updating ratings no longer emits the warning or displays it to users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100