Add a sanity check to reject VCS updates that don't have a version number.

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
This commit is contained in:
Yahnis Elsts 2023-08-23 20:24:28 +03:00
parent 5a270988c5
commit b9aa17be21
1 changed files with 15 additions and 0 deletions

View File

@ -85,6 +85,21 @@ if ( !class_exists(PluginUpdateChecker::class, false) ):
$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() ) {