6

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.)

0

4 Answers 4

5

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
  • 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. Commented Apr 13, 2015 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.

0
3

Did you look here /admin/reports/updates?

3
  • 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.) Commented Apr 13, 2015 at 19:32
  • Did you get this figured out?
    – Heather
    Commented Apr 22, 2015 at 11:53
  • Yes, in the top/accepted answer. Commented Apr 22, 2015 at 15:52
2

In Drupal 8 the right way of managing sites is using composer.

On top of that Drush from version 9 have deprecated all the up commands pm-update, pm-updatecode and pm-updatestatus

Give both points, if you need to get programatically the list of updated modules you can use composer:

composer outdated "drupal/*"

Drush is still used to get the list of security udpates:

drush pm:security

See for more informatio: https://www.drupal.org/docs/updating-drupal/updating-modules-and-themes-using-composer

1
  • 1
    Sorry, when I asked this 5+ years ago, I was asking for D7. I update the ticket to reflect that. Commented Aug 21, 2020 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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