diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 5a2bed5..37c913a 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -620,7 +620,7 @@ public function processForm($form_id, &$form, &$form_state) { // possibly ending execution. We make sure we do not react to the batch // that is already being processed (if a batch operation performs a // self::submitForm). - if ($batch =& batch_get() && !isset($batch['current_set'])) { + if ($batch = &$this->batchGet() && !isset($batch['current_set'])) { // Store $form_state information in the batch definition. // We need the full $form_state when either: // - Some submit handlers were saved to be called during batch @@ -1195,7 +1195,7 @@ public function executeHandlers($type, &$form, &$form_state) { // Check if a previous _submit handler has set a batch, but make sure we // do not react to a batch that is already being processed (for instance // if a batch operation performs a self::submitForm()). - if ($type == 'submit' && ($batch =& batch_get()) && !isset($batch['id'])) { + if ($type == 'submit' && ($batch = &$this->batchGet()) && !isset($batch['id'])) { // Some previous submit handler has set a batch. To ensure correct // execution order, store the call in a special 'control' batch set. // See _batch_next_set(). @@ -1837,4 +1837,11 @@ public function setRequest(Request $request) { $this->request = $request; } + /** + * Wraps batch_get(). + */ + protected function &batchGet() { + return batch_get(); + } + } diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php index 2ff4858..3b7a97f 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php +++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php @@ -16,6 +16,8 @@ /** * Provides a base class for testing form functionality. + * + * @see \Drupal\Core\Form\FormBuilder */ abstract class FormTestBase extends UnitTestCase { @@ -321,11 +323,20 @@ public function drupalStaticReset($name = NULL) { static::$seenIds = array(); } + /** + * {@inheritdoc} + */ + protected function &batchGet() { + $batch = array(); + return $batch; + } + } } namespace { + function test_form_id() { $form['test'] = array( '#type' => 'textfield', @@ -351,10 +362,5 @@ function test_form_id() { ); return $form; } - if (!function_exists('batch_get')) { - function &batch_get() { - $batch = array(); - return $batch; - } - } + }