hook_update_N() documenting $sandbox['#finished']

Created on 10 July 2015, almost 9 years ago
Updated 10 April 2024, 2 months ago

Problem/Motivation

The documentation of hook_update_N() says:

The system will stop iterating this update when $sandbox['#finished'] is left unset or set to a number higher than 1.

This is only kind of true because

  1. Iteration also stops if $sandbox['#finished'] == 1
  2. The update process is properly closed only if $sandbox['#finished'] == 1 since in update_do_one() we have:
  // Record the schema update if it was completed successfully.
  if ($context['finished'] == 1 && empty($ret['#abort'])) {
    drupal_set_installed_schema_version($module, $number);
  }

which means if $sandbox['#finished'] is > 1 then the schema_version for the module won't be updated (even if the updates run successfully).

Proposed resolution

Since

  1. according to the documentation 'finished' values > 1 are already allowed and
  2. the batch API does not differentiate between 1 and >1 'finished' values

I think hook_update_N() should not differentiate between 1 and >1 'finished' values either.

Remaining tasks

Review patch.

API changes

πŸ› Bug report
Status

Needs work

Version

7.0 ⚰️

Component
SystemΒ  β†’

Last updated 2 days ago

No maintainer
Created by

πŸ‡­πŸ‡ΊHungary czigor

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024