filterOutInvokedUpdatesByExtension example

// Set the schema version of update_test_postupdate to a lower version, so     // update_test_postupdate_update_8001() needs to be executed.     $update_registry->setInstalledVersion('update_test_postupdate', 8000);
    $this->drupalGet('admin/reports/status');
    $this->assertSession()->pageTextContains('Out of date');

    // Now cleanup the executed post update functions.     $update_registry->setInstalledVersion('update_test_postupdate', 8001);
    /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
    $post_update_registry = \Drupal::service('update.post_update_registry');
    $post_update_registry->filterOutInvokedUpdatesByExtension('update_test_postupdate');
    $this->drupalGet('admin/reports/status');
    $this->assertSession()->pageTextContains('Out of date');

    $this->drupalGet('admin/reports/status/php');
    $this->assertSession()->statusCodeEquals(200);

    $settings['settings']['sa_core_2023_004_phpinfo_flags'] = (object) [
      'value' => INFO_ALL,
      'required' => TRUE,
    ];
    $this->writeSettings($settings);
    
// The list of extensions installed or uninstalled. In regular operation       // only one of the lists will have a single value. This is because Drupal       // can only install one extension at a time.       $uninstalled_extensions = array_diff($old_extension_list$new_extension_list);
      $installed_extensions = array_diff($new_extension_list$old_extension_list);

      // Set the list of enabled extensions correctly so update function       // discovery works as expected.       $this->enabledExtensions = $new_extension_list;

      foreach ($uninstalled_extensions as $uninstalled_extension) {
        $this->filterOutInvokedUpdatesByExtension($uninstalled_extension);
      }
      foreach ($installed_extensions as $installed_extension) {
        // Ensure that all post_update functions are registered already. This         // should include existing post-updates, as well as any specified as         // having been previously removed, to ensure that newly installed and         // updated sites have the same entries in the registry.         $this->registerInvokedUpdates(array_merge(
          $this->getUpdateFunctions($installed_extension),
          array_keys($this->getRemovedPostUpdates($installed_extension))
        ));
      }
    }
$key_value->set('existing_updates', ['module_b_post_update_a', 'theme_d_post_update_c'])
      ->willReturn(NULL)
      ->shouldBeCalledTimes(1);
    $key_value = $key_value->reveal();

    $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
      'module_a',
      'module_b',
      'theme_d',
    ]$key_value, FALSE);

    $update_registry->filterOutInvokedUpdatesByExtension('module_a');
  }

}
Home | Imprint | This part of the site doesn't use cookies.