Problem/Motivation
The documentation at https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21fo... states (empahsis added):
The 'sandbox' array key is not initially set when this callback is first called, which makes it useful for determining whether it is the first call of the callback or not:
if (empty($context['sandbox'])) { // Perform set-up steps here. }
The words contradict the example.
Steps to reproduce
- use batch_set in a form to create a batch
- inspect the incoming $context variable in the operation function
Expected behaviour from description: array_key_exists('sandbox', $context) === false
Current behaviour: array_key_exists('sandbox', $context) === true
Expected behaviour from example: empty($context['sandbox']) === true
Current behaviour: empty($context['sandbox']) === true
Proposed resolution
Update the documentation to indicate the array key is "empty" rather than "not set".
Remaining tasks
User interface changes
None
API changes
Documenttion only
Data model changes
None
Release notes snippet
None
Issue fork drupal-3307468
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
darvanenComment #4
smustgrave CreditAttribution: smustgrave at Mobomo commentedMakes sense to me.
Comment #5
darvanenThree members of the bug smash initiative (myself, @smustgrave and @ambermatz) believe this to be a bug.
Comment #6
darvanenComment #7
alexpottComment #8
alexpottCommitted and pushed 9514c30ab4 to 10.1.x and 92edba5344 to 10.0.x and f2edbcb391 to 9.5.x and f59520e3bc to 9.4.x. Thanks!
Backported to 9.4.x since this is a docs only change.
Changed the issue title to be a little tighter to the scope of the issue.