You are here

function content_check_update in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6.2 content.install \content_check_update()

Helper function for module updates :

  • checks no updates are pending for content.module
  • checks content module and the module being updated are both enabled.

Parameters

$module: The name of the module being updated.

25 calls to content_check_update()
content_update_6000 in ./content.install
Add module name to fields table to make it easier to identify the fields to delete when a module is uninstalled.
content_update_6001 in ./content.install
Rename node_field and node_field_instance tables.
content_update_6002 in ./content.install
Get rid of automatic per content tables for content types that have no fields. Switching to adding those tables only when needed.
content_update_6003 in ./content.install
'db_columns' column 1st got introduced as 'columns', which is forbidden in MySQL 4. This update function will only be useful for early D6 testers...
content_update_6004 in ./content.install
Index the 'nid' column on data tables to optimize node deletion. Large tables might deserve a multipass update.

... See full list

File

./content.install, line 231

Code

function content_check_update($module = NULL) {
  $ret = array();

  // Check that modules are enabled before running their updates.
  if (!module_exists('content') || $module && !module_exists($module)) {
    drupal_set_message(t("Updates for CCK-related modules are not run until the modules are enabled on the <a href=\"@admin-modules-path\">administer modules page</a>. When you enable them, you'll need to return to <a href=\"@update-php\">update.php</a> and run the remaining updates.", array(
      '@admin-modules-path' => url('admin/build/modules'),
      '@update-php' => base_path() . 'update.php?op=selection',
    )), 'warning', FALSE);

    // The content module is not enabled, nothing else can happen.
    if ($module && !module_exists('content') && module_exists($module)) {
      $query_message = t('!module.module has updates but cannot be updated because content.module is not enabled.<br />If and when content.module is enabled, you will need to re-run the update script. You will continue to see this message until the module is enabled and updates are run.', array(
        '!module' => $module,
      ));
    }
    else {
      $query_message = t('!module.module has updates and is available in the modules folder but is not enabled.<br />If and when it is enabled, you will need to re-run the update script. You will continue to see this message until the module is enabled and updates are run.', array(
        '!module' => $module ? $module : 'content',
      ));
    }
    $ret['#abort'] = array(
      'success' => FALSE,
      'query' => $query_message,
    );
    return $ret;
  }

  // Check that content.module is up-to-date before running field module updates.
  if ($module && drupal_get_installed_schema_version('content', TRUE) < max(drupal_get_schema_versions('content'))) {
    drupal_set_message(t('Some updates are still pending. Please return to <a href="@update-php">update.php</a> and run the remaining updates.', array(
      '@update-php' => base_path() . 'update.php?op=selection',
    )), 'warning', FALSE);
    $ret['#abort'] = array(
      'success' => FALSE,
      'query' => t('Some updates are still pending.<br/>Please re-run the update script.'),
    );
    return $ret;
  }

  // If everything is OK and updates are not aborted, make sure
  // content_associate_fields() gets run. With all the complexity of
  // the dependent updates, it can get missed when an update is aborted.
  // It won't hurt anything to do this more than once in order to be sure
  // it doesn't get skipped. Without this step, we can end up with
  // field modules that are enabled and updated, but not marked as active
  // in the content_node_field table.
  if ($module and module_exists($module)) {
    content_associate_fields($module);
  }
}