Block API Calls to Bitbucket

Updated 7 months ago
by Dave Warfel

NOTE
One of LearnDash’s support reps posted a long response to this issue in the LearnDash Facebook group. It’s a bit more technical than this article, but it’s worth reading, and has some important caveats before you use this code snippet. And he knows a lot more about exactly what it’s doing and how it works than I do. I’ve included it at the end of this article.

If you’re evaluating the performance of your LearnDash site, you might notice a common warning often found in the Query Monitor plugin under “HTTP API Calls.” It looks something like this:

429 too many requests for LearnDash BitBucket API

It’s a GET request, with the following parameters:

URL

https://bitbucket.org/learndash/learndash-add-ons/get/stable.zip?...

STATUS

429 Too Many Requests

CALLER

LearnDash_BitBucket_API->get_bitbucket_repositories()
wp-content/plugins/sfwd-lms/includes/class-ld-bitbucket-api.php:249
LearnDash_Addon_Updater->get_addon_plugins()
wp-content/plugins/sfwd-lms/includes/class-ld-addons-updater.php:565
nss_plugin_updater_sfwd_lms->get_plugin_readme()
wp-content/plugins/sfwd-lms/includes/ld-autoupdate.php:392
nss_plugin_updater_sfwd_lms->get_plugin_upgrade_notice()
wp-content/plugins/sfwd-lms/includes/ld-autoupdate.php:400
nss_plugin_updater_sfwd_lms->admin_notice_upgrade_notice()
wp-content/plugins/sfwd-lms/includes/ld-autoupdate.php:255
do_action('admin_notices')
wp-includes/plugin.php:470

Some of your line numbers might be different, but it will start with LearnDash_BitBucket_API->get_bitbucket_repositories().

COMPONENT

Plugin: sfwd-lms

What is it?

The LearnDash plugin includes some code that allows it to check its own servers for updates. This is how it presents updates to you on your Plugins page in the WordPress admin area. And when you update to a newer version, your website asks LearnDash’s server for the new files, and LearnDash’s server responds with the files.

However, I believe that code is checking LearnDash’s servers pretty frequently for updates, and this warning is telling you it’s happening quite frequently.

What is Bitbucket?

Bitbucket is a third-party solution for managing & hosting software code. LearnDash uses Bitbucket as a way to manage the changes in its code over time, as well as to deliver new updates to the plugin to its users.

How to block Bitbucket API calls from LearnDash?

WARNING
Blocking Bitbucket API calls will mean you need to manually check for updates to LearnDash & its add-ons.

The frequency of these calls might be putting excess strain on your web server, although according to LearnDash, this has no affect on your site’s performance. If you’d like to stop this from happening, you can add the following code to your wp-config.php file, just before the line that says:

/* That's all, stop editing! Happy blogging. */

WARNING
Be very careful editing the wp-config.php file. One small mistake can bring your entire website down.

For LearnDash 3.1.8 & Above

if ( ! defined( 'LEARNDASH_UPDATES_ENABLED' ) ) {
	define( 'LEARNDASH_UPDATES_ENABLED', false );
}

For LearnDash 3.1.7 & Below


if ( ! defined( 'LEARNDASH_ADDONS_UPDATER' ) ) {
	define( 'LEARNDASH_ADDONS_UPDATER', false );}
 
if ( ! class_exists( 'LearnDash_Addon_Updater' ) ) {
	class LearnDash_Addon_Updater {
		protected static $instance = null;
 
		public static function get_instance() {
			if ( ! isset( static::$instance ) ) {
				static::$instance = new static();
			}

			return static::$instance;
		}

		public function __call( $name, $arguments ) {
			return;
		}
	}
}

Original Source: developers.learndash.com

LearnDash Support’s Response

A member of LearnDash’s support team had this to say in response to a user who was experiencing this in Query Monitor:

“The slowness issues experienced by [user] on the linked topic was an issue with his hosting server trying to connect to our BitBucket repository over IPv6. He had to eventually have his hosting provider sort it out on their end and it required rebooting a router at the host as the outbound traffic from the hosting server to the BitBucket repository over IPv6 was failing.

Going back to the initial question… these failed requests can be ignored. It just signals that our add-on repository “bucket” has denied the request from your site to check for an update to our add-ons. These checks happen multiple times every hour and the bucket we host the add-ons at has a limit per hour on the amount of requests that can be made. Additionally, this warning is only shown in Query Monitor and doesn’t affect the performance of a site from what we have found.

If you go to LearnDash LMS > Addons in the WP admin area and see that warning in Query Monitor, click on the Check Updates button at the top right of the list of add-ons. Once the refresh happens, you may see that Query Monitor no longer shows that warning for the “429 too many requests” failure. This is because for that particular request, the bucket allowed a request from your site to check for any updates from our add-ons. If you check for updates again, the next request may fail or the next 5 checks may succeed or a combination of both.

Having these failed requests really doesn’t cause any issues other than maybe not seeing that one of our add-ons has an update available for 30 minutes to an hour. Eventually though, one of these requests will go through within a short period of time and you’ll be notified of any available updates to our add-ons, if you are using them.

You can disable the check by adding this code to your wp-config.php file:

define( 'LEARNDASH_ADDONS_UPDATER', false );

But you will then have to manually check for any updates to the add-ons you are using and install those manually.”

All CSS code should either be placed in a child theme’s main CSS file (typically style.css), or the Additional CSS area of the WordPress Customizer.

How to Add CSS to Your Site

Forum Rules

Be Kind & Patient

We’re here to learn and/or help each other. Please don’t be mean, rude, or condescending. Treat all members the way you should be treating dogs and your elders—with the utmost love & respect.

External Links

✅ Other websites that add value, help solve problems & contribute to the discussion. ❌ Affiliate links are prohibited. (Site owners may use affiliate links to help support the site.)

Promotion

✅ You may promote your own products/services if they are relevant to an existing discussion. You must disclose your relationship with the product(s).
❌ You may not create new posts simply to promote your products.

Non-LearnDash Topics

❌ General (free) Forum: Only LearnDash-specific topics are allowed.
✅ Premium Forums: You are allowed to post other questions tangentially related to LearnDash. Please use the appropriately named forum. If it doesn’t exist, use the “LearnDash Integrations” forum.

Our Right to Remove

We reserve the right to remove any content, at any time, for any reason. We can also merge one post with another. We will exercise caution when removing content and always try to provide an explanation.