function UpdateHookRegistry::markFutureUpdateEquivalent
Same name in other branches
- 10 core/lib/Drupal/Core/Update/UpdateHookRegistry.php \Drupal\Core\Update\UpdateHookRegistry::markFutureUpdateEquivalent()
Marks a future update as equivalent to the current update running.
Updates can be marked as equivalent when they are backported to a previous, but still supported, major version. For example:
- A 2.x hook_update_N() would be added as normal, for example: MODULE_update_2005().
- When that same update is backported to 1.x, it is given its own update number, for example: MODULE_update_1040(). In this update, a call to
\Drupal::service('update.update_hook_registry')->markFutureUpdateEquivalent(2005, '2.10');
is added to ensure that a site that has run this update does not run MODULE_update_2005().
Parameters
int $future_update_number: The future update number.
string $future_version_string: The version that contains the future update.
File
-
core/
lib/ Drupal/ Core/ Update/ UpdateHookRegistry.php, line 209
Class
- UpdateHookRegistry
- Provides module updates versions handling.
Namespace
Drupal\Core\UpdateCode
public function markFutureUpdateEquivalent(int $future_update_number, string $future_version_string) : void {
[
$module,
$ran_update_number,
] = $this->determineModuleAndVersion();
if ($ran_update_number > $future_update_number) {
throw new \LogicException(sprintf('Cannot mark the update %d as an equivalent since it is less than the current update %d for the %s module ', $future_update_number, $ran_update_number, $module));
}
$data = $this->equivalentUpdates
->get($module, []);
// It does not matter if $data[$future_update_number] is already set. If two
// updates are causing the same update to be marked as equivalent then the
// latest information is the correct information to use.
$data[$future_update_number] = [
'ran_update' => $ran_update_number,
'future_version_string' => $future_version_string,
];
$this->equivalentUpdates
->set($module, $data);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.