function UpdateHookRegistry::markFutureUpdateEquivalent

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Update/UpdateHookRegistry.php \Drupal\Core\Update\UpdateHookRegistry::markFutureUpdateEquivalent()
  2. 10 core/lib/Drupal/Core/Update/UpdateHookRegistry.php \Drupal\Core\Update\UpdateHookRegistry::markFutureUpdateEquivalent()

Marks a future update as equivalent to the current update running.

To register equivalent updates use the attribute \Drupal\Core\Update\Attribute\MarkFutureUpdateEquivalent.

@todo Uncomment the new $module and $ran_update_number method parameters before drupal:13.0.0. https://www.drupal.org/node/3617733

@internal

Parameters

int $future_update_number: The future update number.

string $future_version_string: The version that contains the future update. phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch

string $module: The module containing the update. Will be determined from stack trace if not set. phpcs:ignore Drupal.Commenting.FunctionComment.ExtraParamComment

int $ran_update_number: The current update number. Will be determined from stack trace if not set.

See also

\Drupal\Core\Update\Attribute\MarkFutureUpdateEquivalent

File

core/lib/Drupal/Core/Update/UpdateHookRegistry.php, line 215

Class

UpdateHookRegistry
Provides module updates versions handling.

Namespace

Drupal\Core\Update

Code

public function markFutureUpdateEquivalent(int $future_update_number, string $future_version_string) : void {
  $arguments = func_get_args();
  $module = $arguments[2] ?? NULL;
  $ran_update_number = $arguments[3] ?? NULL;
  if (!$module || !$ran_update_number) {
    @trigger_error('Calling ' . __METHOD__ . '() without both the $module and $ran_update_number arguments is deprecated in drupal:11.5.0 and they will be required in drupal:13.0.0. See https://www.drupal.org/node/3572245', E_USER_DEPRECATED);
    [$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.