Automattic / Automattic/crowdsignal-plugin

Error updating ratings

Open
#26 0 comments 0 reactions 0 assignees View on GitHub
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/

![image](https://user-images.githubusercontent.com/157240/58812738-d6954080-85f8-11e9-90aa-5ff791da64a9.png)

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.