YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.22k stars 403 forks source link

GitHubApi - Download Not Found - Case Sensitivity Bugfix #360

Open gfullen opened 4 years ago

gfullen commented 4 years ago

Spent the better bar of a 8 hour day trying to figure this out haha.

So when creating repositories in GitHub, you can provide a friendly name and a slug will be generated from that. The issue is that GitHub doesn't force the generated slug to lower case.

Therefore, when you're comparing the request url with the download url here https://github.com/YahnisElsts/plugin-update-checker/blob/master/Puc/v4p9/Vcs/GitHubApi.php#L405

it will fail the comparison and not attach the necessary access token. I changed that line to

if ($this->isAuthenticationEnabled() && (strpos(mb_strtolower($url), mb_strtolower($repoApiBaseUrl))) === 0) {

and it's working as expected. I tried to submit a pull request but I've never done on another project and it was asking me to authenticate. So I just decided to explain it here haha.

YahnisElsts commented 4 years ago

I'm too lazy to create a new repository and a plugin to test this, but could you work around this issue by changing the slug in the repository URL that you provide to the update checker?

For example, if you're doing this:

$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
    'https://github.com/user-name/Repo-Name/',
    __FILE__
);

Try this instead:

$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
    'https://github.com/user-name/repo-name/',
    __FILE__
);