foreach (drupal_get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) {

The function's documentation doesn't say this usage is valid.

Comments

joachim created an issue. See original summary.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

maliknaik’s picture

Modified the doc block.

maliknaik’s picture

Assigned: Unassigned » maliknaik
Status: Active » Needs review
joachim’s picture

That's a good start, but it shoul also say what it means to pass in NULL.

mmjvb’s picture

And returning an array in addition to string|int.

maliknaik’s picture

StatusFileSize
new534 bytes

When the first parameter is set to NULL then it gets the information about all the modules in the system.

function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
  $versions = &drupal_static(__FUNCTION__, []);

  if ($reset) {
    $versions = [];
  }

  if (!$versions) {
    if (!$versions = \Drupal::keyValue('system.schema')->getAll()) {
      $versions = [];
    }
  }

  if ($array) {
    return $versions;
  }
  else {
    return isset($versions[$module]) ? $versions[$module] : SCHEMA_UNINSTALLED;
  }
}
mmjvb’s picture

No, it always gets all versions upon first call. Only when $array is TRUE it returns all. Which is why it needs the array added as return value. The $module is irrelevant/disgarded when $array is TRUE. So, it could be NULL, but its value is ignored/not used. When $array is FALSE, $module shouldn't be NULL and it returns SCHEMA_UNINSTALLED when it does.

maliknaik’s picture

StatusFileSize
new782 bytes

@mmjvb, I've added the array as one of the return type and also changed the description for the first parameter.

mmjvb’s picture

The description of the return type should mention it returns the version of each discovered module (array), the version of module requested (string), SCHEMA_UNINSTALLED (int) when that module is uninstalled from database.

maliknaik’s picture

StatusFileSize
new1.06 KB

@mmjvb, I've updated the description.

Oops, I've added the wrong patches previously.

mmjvb’s picture

Although I am not native speaker, believe that description not to be a proper sentence. Couldn't find a proper example that quickly on explaining the @return. There might even be standards for it. Maybe somebody else knows.

maliknaik’s picture

StatusFileSize
new1.04 KB

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Assigned: maliknaik » Unassigned
Status: Needs review » Closed (duplicate)
Issue tags: +Bug Smash Initiative
Related issues: +#2124069: Convert schema.inc to the update.update_hook_registry service (UpdateHookRegistry)

Thanks everyone for working on this.

Looking into this I find that this has been addressed in #2124069: Convert schema.inc to the update.update_hook_registry service (UpdateHookRegistry). Therefor closing as a duplicate.