Skip to content

Commit

Permalink
Add a sanity check to reject VCS updates that don't have a version nu…
Browse files Browse the repository at this point in the history
…mber.

This can happen when PUC is configured to use a branch (as opposed to tags or releases) and it fails to retrieve the main plugin file from the repository, e.g. due to API rate limits. Then it can't get the "Version" header from the main plugin file.

See #526
  • Loading branch information
YahnisElsts committed Aug 23, 2023
1 parent 5a27098 commit b9aa17b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Puc/v5p2/Vcs/PluginUpdateChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ public function requestInfo($unusedParameter = null) {
$this->setInfoFromHeader($remoteHeader, $info);
}

//Sanity check: Reject updates that don't have a version number.
//This can happen when we're using a branch, and we either fail to retrieve the main plugin
//file or the file doesn't have a "Version" header.
if ( empty($info->version) ) {
do_action(
'puc_api_error',
new \WP_Error(
'puc-no-plugin-version',
'Could not find the version number in the repository.'
),
null, null, $this->slug
);
return null;
}

//Try parsing readme.txt. If it's formatted according to WordPress.org standards, it will contain
//a lot of useful information like the required/tested WP version, changelog, and so on.
if ( $this->readmeTxtExistsLocally() ) {
Expand Down

0 comments on commit b9aa17b

Please sign in to comment.