Skip to content

core_needs_update gets set as true if there are no updates available #1

@juhalehtonen

Description

@juhalehtonen

Logically it would seem that we are trying to check if the count of available updates is higher than zero, but that's not what actually happens. Looking at line 90 of https://github.com/evermade/wordpress-version-dashboard-client/blob/master/version-dashboard-client.php#L90 , it seems like the issue is as follows:

We set core_needs_update with this:
core_needs_update' => isset($coreInformation->updates) && count($coreInformation->updates) > 0

However, count($coreInformation->updates) returns 1 because if there are no updates, the transient returns false, and count(false) returns 1. The return value of get_site_transient() is further documented at https://developer.wordpress.org/reference/functions/get_site_transient/.

So, in the end we end up comparing if 1 > 0, and thus we get the value true here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions