In update_get_updates_list() and $updates array is created by a call to drupal_get_schema_versions($module) which returns an array of update numbers or FALSE if no updates are pending.

Further in update_get_updates_list() the function array_combine is used to copy the values of this $updates array to the keys and values of the $updates array. Then a foreach loop iterates over the array_keys($updates). This makes the combination of array_combine and array_keys reduntant and means we can just iterate over the $updates array as returned by drupal_get_schema_versions. The case where that variable equals FALSE is handled by a separate if statement guarding this code.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kingdutch created an issue. See original summary.

Kingdutch’s picture

Assigned: Kingdutch » Unassigned
Status: Active » Needs review
FileSize
892 bytes

Patch attached

Dinesh18’s picture

I agree it makes redundant by using unnecessary array operations. Manually tested the patch. It looks good
We require tests as well.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

All the update path tests we have already test this implicitly.

  • larowlan committed a64943d on 8.5.x
    Issue #2880387 by Kingdutch: Avoid unnecessary array operations in...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Reviewed the remainder of that function and $updates is not used again, so the change in structure has no impact on subsequent code

Committed as a64943d and pushed to 8.5.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.