class MarkFutureUpdateEquivalent

Same name and namespace in other branches
  1. main core/lib/Drupal/Core/Update/Attribute/MarkFutureUpdateEquivalent.php \Drupal\Core\Update\Attribute\MarkFutureUpdateEquivalent

Attribute used by hook_update_N() to register an equivalent update.

Updates can be registered as equivalent when they are backported to a previous, but still supported, major version. Update functions using this attribute will register the update as equivalent to the given future update. The future update is specified by future hook_update_N number and the future module version. The update itself can be no-op.

By itself, hook_update_N() hooks do not run on module install. However, the presence of the attribute on a hook_update_N() will register the equivalent update when the module is installed.

Example:

use Drupal\Core\Update\Attribute\MarkFutureUpdateEquivalent;
function MODULE_update_1040() : void {
}

Here, database update MODULE_update_2005() is added to version 2.x of MODULE. When that same update is backported to 1.x, it is given its own update number, MODULE_update_1040(). This ensures that a site that has run this MODULE_update_1040() does not also run MODULE_update_2005().

Attributes

#[\Attribute(\Attribute::TARGET_FUNCTION)]

Hierarchy

Expanded class hierarchy of MarkFutureUpdateEquivalent

See also

Update API

5 files declare their use of MarkFutureUpdateEquivalent
DatabaseUpdate.php in core/lib/Drupal/Core/Update/DatabaseUpdate.php
equivalent_update_test.install in core/modules/system/tests/modules/equivalent_update_test/equivalent_update_test.install
equivalent_update_test_attribute_install.install in core/modules/system/tests/modules/equivalent_update_test_attribute_install/equivalent_update_test_attribute_install.install
ModuleInstaller.php in core/lib/Drupal/Core/Extension/ModuleInstaller.php
system.install in core/modules/system/system.install
Install, update and uninstall functions for the system module.

File

core/lib/Drupal/Core/Update/Attribute/MarkFutureUpdateEquivalent.php, line 36

Namespace

Drupal\Core\Update\Attribute
View source
readonly class MarkFutureUpdateEquivalent {
  public function __construct(public int $futureUpdateNumber, public string $futureVersionString) {
  }

}

Members

Title Sort descending Modifiers Object type Summary
MarkFutureUpdateEquivalent::__construct public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.