Commit 241aa0d5 authored by catch's avatar catch
Browse files

Issue #3210931 by andypost: Remove deprecated update.inc functions

parent 886ca0b6
Loading
Loading
Loading
Loading
+0 −60
Original line number Diff line number Diff line
@@ -12,42 +12,6 @@
use Drupal\Core\Extension\Exception\UnknownExtensionException;
use Drupal\Core\Utility\Error;

/**
 * Tests the compatibility of a module or theme.
 *
 * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct
 *   replacement is provided.
 *
 * @see https://www.drupal.org/node/3150727
 * @see \Drupal\Core\Extension\ExtensionList::checkIncompatibility()
 */
function update_check_incompatibility($name, $type = 'module') {
  @trigger_error('update_check_incompatibility() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3150727', E_USER_DEPRECATED);
  static $themes, $modules;

  // Store values of expensive functions for future use.
  if (empty($themes) || empty($modules)) {
    // We need to do a full rebuild here to make sure the database reflects any
    // code changes that were made in the filesystem before the update script
    // was initiated.
    $themes = \Drupal::service('theme_handler')->rebuildThemeData();
    $modules = \Drupal::service('extension.list.module')->reset()->getList();
  }

  if ($type == 'module' && isset($modules[$name])) {
    $file = $modules[$name];
  }
  elseif ($type == 'theme' && isset($themes[$name])) {
    $file = $themes[$name];
  }
  if (!isset($file)
      || $file->info['core_incompatible']
      || version_compare(phpversion(), $file->info['php']) < 0) {
    return TRUE;
  }
  return FALSE;
}

/**
 * Returns whether the minimum schema requirement has been satisfied.
 *
@@ -146,30 +110,6 @@ function _update_fix_missing_schema() {
  }
}

/**
 * Forces a module to a given schema version.
 *
 * This function is rarely necessary.
 *
 * @param string $module
 *   Name of the module.
 * @param string $schema_version
 *   The schema version the module should be set to.
 *
 * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. No direct
 *   replacement is provided.
 *
 * @see https://www.drupal.org/node/3210925
 */
function update_set_schema($module, $schema_version) {
  @trigger_error('update_set_schema() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3210925', E_USER_DEPRECATED);
  \Drupal::service('update.update_hook_registry')->setInstalledVersion($module, $schema_version);
  \Drupal::service('extension.list.profile')->reset();
  \Drupal::service('extension.list.module')->reset();
  \Drupal::service('extension.list.theme_engine')->reset();
  \Drupal::service('extension.list.theme')->reset();
}

/**
 * Implements callback_batch_operation().
 *
+0 −19
Original line number Diff line number Diff line
@@ -24,25 +24,6 @@ protected function setUp(): void {
    include_once $this->root . '/core/includes/update.inc';
  }

  /**
   * Tests update_check_incompatibility() function.
   */
  public function testUpdateCheckIncompatibility() {
    $this->expectDeprecation('update_check_incompatibility() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3150727');
    $this->assertTrue(update_check_incompatibility('incompatible_module'));
    $this->assertFalse(update_check_incompatibility('system'));
  }

  /**
   * Tests update_set_schema() function.
   */
  public function testUpdateSetSchema() {
    $this->expectDeprecation('update_set_schema() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3210925');
    update_set_schema('update_test_schema', 8003);
    // Ensure schema has changed.
    $this->assertEquals(8003, \Drupal::keyValue('system.schema')->get('update_test_schema'));
  }

  /**
   * Deprecation testing for drupal_get_schema_versions function.
   *