5

I need to be able to easily get a list of available updates for a site.

I've come across the update_get_update_list() function, but that only returns an array of " information about database updates that need to be run, and any updates that are not going to proceed due to missing requirements." I want the list that gets displayed on the admin/modules/update page, but can't seem to find any way to do that through the core update module, and want to avoid using grep on a drush up -n call (as that feels kind of hacky.)

4

Assuming you need this info programatically, you may be looking for update_calculate_project_data():

Calculates the current update status of all projects on the site.

The results of this function are expensive to compute, especially on sites with lots of modules or themes, since it involves a lot of comparisons and other operations. Therefore, we cache the results into the {cache_update} table using the 'update_project_data' cache ID. However, since this is not the data about available updates fetched from the network, it is ok to invalidate it somewhat quickly. If we keep this data for very long, site administrators are more likely to see incorrect results if they upgrade to a newer version of a module or theme but do not visit certain pages that automatically clear this cache.

The return value is:

An array of installed projects with current update status information.

update_calculate_project_data() requires an argument of all the available/enabled modules.

Running this...

module_load_include('inc', 'update', 'update.report');
$available = update_get_available(TRUE);
$data = update_calculate_project_data($available);

... will leave $data as an array of all available/enabled modules, with their corresponding existing_version, recommended, and latest_version info. If only the modules with updates are necessary, they can be filtered out by comparing those versions.

  • 1
    I'm so close! Heh. I've done this: module_load_include('inc', 'update', 'update.report'); $available = update_get_available(TRUE); $data = update_calculate_project_data($available); and I get a list of all enabled modules, with their existing/recommended/latest releases. I was hoping for something a little more direct, but this definitely usable. – UnsettlingTrend Apr 13 '15 at 19:34
5

As far as I'm concerned there are three ways you can achieve this:

  1. You can use the Drupal UI /admin/reports/updates
  2. You can use Drush drush ups
  3. You can use a Third Party Service Drupal Status.

I wrote an article that explains how to integrate multiple Drupal website with Drupal Status.

3

Did you look here /admin/reports/updates?

  • Sort of. I'm looking to do this programmatically, but the update.report.inc file got me down the right track so far (I think.) – UnsettlingTrend Apr 13 '15 at 19:32
  • Did you get this figured out? – Heather Apr 22 '15 at 11:53
  • Yes, in the top/accepted answer. – UnsettlingTrend Apr 22 '15 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.