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

Azure DevOps Api #480

Closed dvalley56 closed 2 years ago

dvalley56 commented 2 years ago

I have tested this update checker in github repo, and it is working perfectly as expected. But I am looking for this thing to work for Azure Devops repo too. How can I do this?? I tried doing using Azure url with personal access token, but it isn't working. I know this isn't an issue but I don't know where else I can ask.

YahnisElsts commented 2 years ago

I'm not familiar with Azure DevOps. If it has its own API, you would probably need a custom implementation for that; you can't just reuse the same code that works for GitHub.

dvalley56 commented 2 years ago

Thank you sir for glancing the question. I am new to wordpress or php, I would be glad if you can give me pointer from where to start this. I want the dame thing your plugin does but using azure repo. πŸ™‚πŸ™‚πŸ™‚

YahnisElsts commented 2 years ago

If you're not very familiar with PHP, I'm afraid that this might be a difficult task. That said, if you want to try anyway, my suggestion would be to look at the GitHub integration code and see if you can make something similar for Azure DevOps.

As I mentioned, I'm not really familiar with Azure, but it looks like this part of the documentation might be a good place to start: https://docs.microsoft.com/en-us/rest/api/azure/devops/git/?view=azure-devops-rest-7.1

dvalley56 commented 2 years ago

Thank you Sir, I am past this. Currently I get the update status from my latest release, but when I click update now I get some wierd error (doesn't get logged in debug.log). I am stuck there now.

image Check for update is working now.

image Now getting this error on clicking update now (error 203, i.e. authentication is not set).

I would like to know which methods are called behind that button.

The problem is in azure api we cannot get our repo content in base64, we can get the zip file. So I don't know what to do next, When the getRemoteFile is called we get all gibberish, I even dont know if its encoded or ASCII or whatever. image

Thank you so much for checking this replies !!

YahnisElsts commented 2 years ago

Basically, when you click the "update now" link, WordPress uses the download_url field from the update metadata to download the update. The download URL should point to a ZIP file.

Since I've never used the Azure API, I can't really say why you're getting that particular error. Maybe there's some authentication-related query parameter that you need to add to the download URL? Or a specific HTTP header that you need to send?

dvalley56 commented 2 years ago

Basically, when you click the "update now" link, WordPress uses the download_url field from the update metadata to download the update. The download URL should point to a ZIP file.

Since I've never used the Azure API, I can't really say why you're getting that particular error. Maybe there's some authentication-related query parameter that you need to add to the download URL? Or a specific HTTP header that you need to send?

I am passed that point and now as you said authentication-related parameter but not query, the header parameter Authorization. I get this error only when clicking on update now, and for other request like check for updates it is working fine.

Also for some reason '&#8230' this is getting added at the end of the download url and that url doesn't work as expected in postmen doesn't work.

image

YahnisElsts commented 2 years ago

You could use the poorly documented http_request_args filter to add the header to the request. The available $args are generally described here. Please take care to add the header only to your own requests, not to all requests sent by WordPress.

It looks like &#8230 is an ellipsis: "...". I suspect that it's just being added to the end of the line to show that something is "in progress"; it's not actually part of the URL.

dvalley56 commented 2 years ago

You could use the poorly documented http_request_args filter to add the header to the request. The available $args are generally described here. Please take care to add the header only to your own requests, not to all requests sent by WordPress.

It looks like &#8230 is an ellipsis: "...". I suspect that it's just being added to the end of the line to show that something is "in progress"; it's not actually part of the URL.

In which file to add this filter? can you help πŸ˜•πŸ˜•

YahnisElsts commented 2 years ago

Since it's a filter, it doesn't really matter where you put it. You just need to make sure that the code that adds the filter runs before the HTTP request happens.

If you're not familiar with hooks and filters, you could try searching for some WordPress filter tutorials. Here's a short one.

dvalley56 commented 2 years ago

Since it's a filter, it doesn't really matter where you put it. You just need to make sure that the code that adds the filter runs before the HTTP request happens.

If you're not familiar with hooks and filters, you could try searching for some WordPress filter tutorials. Here's a short one.

I check the add filter it works, but not for update now. The filter option works perfectly for check for update and view detail, but it is not working for update now button.

This is the last thing for which I require your help πŸ’― , I checked my current code by making my repo public and it is working great. But when it is private there is the error.

If u want a look at the code, I can share.

YahnisElsts commented 2 years ago

Make sure that your filter is executed in all relevant contexts. I think the "update now" link uses AJAX by default, so check if your code might have some if() conditions or hooks that would prevent it from running in an AJAX request.

dvalley56 commented 2 years ago

Make sure that your filter is executed in all relevant contexts. I think the "update now" link uses AJAX by default, so check if your code might have some if() conditions or hooks that would prevent it from running in an AJAX request.

Thank you so much sir, the updater is working perfectly😁😁😁. Just one problem more, my pluging code is not working now :( , in the main plugin file where I added required code. After removing the the require code my plugin is working perfectly.

In my plugin there is an add_action('wpcf7_before_send_mail', 'send post data to external api'). What should I do now?

YahnisElsts commented 2 years ago

Do you mean that you literally have that line of code in your plugin? I don't know what the plugin is supposed to do, but I'm fairly certain that 'send post data to external api' is not a valid action callback. You'll probably have to either get rid of that line, or actually implement a function or method that can be used as a callback.

dvalley56 commented 2 years ago

actually implement a function or method that can be used as a callback.

No not literally, not that dumbπŸ˜‚ πŸ˜‚ .

add_action('wpcf7_before_send_mail', 'send post data to external api');
function send post data to external api(){
    // here is my function to send data to external api
}

I want to thank you for making such a wonderful plugin. Your plugin is working perfectly now, so I will close this issue or whatever it is :).

rolltidehero commented 2 years ago

actually implement a function or method that can be used as a callback.

No not literally, not that dumbπŸ˜‚ πŸ˜‚ .

add_action('wpcf7_before_send_mail', 'send post data to external api');
function send post data to external api(){
    // here is my function to send data to external api
}

Save

I want to thank you for making such a wonderful plugin. Your plugin is working perfectly now, so I will close this issue or whatever it is :).

As a way of saying thanks, can you write up a documentation\guide for your steps on getting it working with Azure?

Thanks

dvalley56 commented 2 years ago

Sure why not, but I will need some of my free time.

I saw this on my mail the day you commented, but I forgot to leave a reply :}.