Self-hosted plugin update problems

Ok, this is a working solution but a hacky one. First, the explanation.

After much gnashing of teeth and error logging I’ve discovered that the filter ‘pre_set_site_transient_update_plugins’ is called at least twice during a plugin update check. Sometimes, the passed array has the ‘checked’ array attached to it, sometimes it does not. I have no idea why but when it does NOT have the checked array, the site transient ‘update_plugins’ does.

It appears that the only way to keep my plugin update in that transient is to return it with the ‘checked’ array included. Again, no idea why. So, I cheat:

$transient = get_site_transient('update_plugins');

if (empty($checked_data->checked)) {
   if (empty($transient->checked)) {
       return $checked_data;
   } else {
       $checked_data = $transient;
   }
}

// proceed to get the plugin update data

So, I check to see if either one has the ‘checked’ array and if it does, I use that one to add my plugin data to.

The net result is, my plugin update shows up where its supposed to and even through subsequent checks, it doesn’t get removed.

If you know of a proper solution, PLEASE let me know. Somehow, I kinda expect this to fail at some point.