Verified Commit 04e1bb20 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3442002 by alexpott, larowlan: @larowlan review on #3439923

(cherry picked from commit 0f5f94f92a3a93e9f38edec75e848365c0483968)
parent 28cf67bd
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -31,10 +31,10 @@
 *   \Drupal\Core\Config\Action\ConfigActionPluginInterface, in namespace
 *   Plugin\ConfigAction under your module namespace. For more information about
 *   creating plugins, see the @link plugin_api Plugin API topic. @endlink
 * - Config action plugins use the annotations defined by
 *  \Drupal\Core\Config\Action\Annotation\ConfigAction. See the
 *   @link annotation Annotations topic @endlink for more information about
 *   annotations.
 * - Config action plugins use the attributes defined by
 *  \Drupal\Core\Config\Action\Attribute\ConfigAction. See the
 *   @link attribute Attributes topic @endlink for more information about
 *   attributes.
 *
 * Further information and examples:
 * - \Drupal\Core\Config\Action\Plugin\ConfigAction\EntityMethod derives
@@ -97,7 +97,10 @@ public function __construct(
   *   action plugin ID or a shorthand action ID that is available for the
   *   entity type of the provided configuration name.
   * @param string $configName
   *   The configuration name.
   *   The configuration name. This may be the full name of a config object, or
   *   it may contain wildcards (to target all config entities of a specific
   *   type, or a subset thereof). See
   *   ConfigActionManager::getConfigNamesMatchingExpression() for more detail.
   * @param mixed $data
   *   The data for the action.
   *
@@ -105,6 +108,8 @@ public function __construct(
   *   Thrown when the config action cannot be found.
   * @throws \Drupal\Core\Config\Action\ConfigActionException
   *   Thrown when the config action fails to apply.
   *
   * @see \Drupal\Core\Config\Action\ConfigActionManager::getConfigNamesMatchingExpression()
   */
  public function applyAction(string $action_id, string $configName, mixed $data): void {
    if (!$this->hasDefinition($action_id)) {
+27 −28
Original line number Diff line number Diff line
@@ -252,7 +252,15 @@ public function getCollectionName() {
  public function checkpoint(string|\Stringable $label): Checkpoint {
    // Generate a new ID based on the state of the current active checkpoint.
    $active_checkpoint = $this->checkpoints->getActiveCheckpoint();
    if ($active_checkpoint instanceof Checkpoint) {
    if (!$active_checkpoint instanceof Checkpoint) {
      // @todo https://www.drupal.org/i/3408525 Consider options for generating
      //   a real fingerprint.
      $id = hash('sha1', random_bytes(32));
      return $this->checkpoints->add($id, $label);
    }

    // Determine if we need to create a new checkpoint by checking if
    // configuration has changed since the last checkpoint.
    $collections = $this->getAllCollectionNames();
    $collections[] = StorageInterface::DEFAULT_COLLECTION;
    foreach ($collections as $collection) {
@@ -270,21 +278,12 @@ public function checkpoint(string|\Stringable $label): Checkpoint {
      // Use json_encode() here because it is both quicker and results in
      // smaller output than serialize().
      $id = hash('sha1', ($active_checkpoint->parent ?? '') . json_encode($current_checkpoint_data));
        $active_checkpoint = $this->checkpoints->add($id, $label);
      return $this->checkpoints->add($id, $label);
    }
      else {

    $this->logger?->notice('A backup checkpoint was not created because nothing has changed since the "{active}" checkpoint was created.', [
      'active' => $active_checkpoint->label,
    ]);
      }
    }
    else {
      // @todo https://www.drupal.org/i/3408525 Consider options for generating
      //   a real fingerprint.
      $id = hash('sha1', random_bytes(32));
      $active_checkpoint = $this->checkpoints->add($id, $label);
    }

    return $active_checkpoint;
  }

+4 −6
Original line number Diff line number Diff line
@@ -143,10 +143,12 @@ private static function parse(string $file): array {
      'install' => new Optional([
        new All([
          new Type('string'),
          new Sequentially([
            new NotBlank(),
            new Callback(self::validateExtensionIsAvailable(...)),
          ]),
        ]),
      ]),
      'config' => new Optional([
        new Collection([
          // Each entry in the `import` list can either be `*` (import all of
@@ -211,10 +213,6 @@ private static function parse(string $file): array {
   * @see \Drupal\Core\Extension\ExtensionList::getAllAvailableInfo()
   */
  private static function validateExtensionIsAvailable(string $value, ExecutionContextInterface $context): void {
    if (empty($value)) {
      return;
    }

    $name = Dependency::createFromString($value)->getName();
    $all_available = \Drupal::service(ModuleExtensionList::class)->getAllAvailableInfo() + \Drupal::service(ThemeExtensionList::class)->getAllAvailableInfo();
    if (!array_key_exists($name, $all_available)) {
+0 −5
Original line number Diff line number Diff line
@@ -58,11 +58,6 @@ protected function configure(): void {
  protected function execute(InputInterface $input, OutputInterface $output): int {
    $io = new SymfonyStyle($input, $output);

    if (PHP_VERSION_ID < 80100) {
      $io->error('Recipes require PHP 8.1');
      return 1;
    }

    $recipe_path = $input->getArgument('path');
    if (!is_string($recipe_path) || !is_dir($recipe_path)) {
      $io->error(sprintf('The supplied path %s is not a directory', $recipe_path));