Commit f9189034 authored by Dries's avatar Dries

- Patch #408024 by brianV et al: rename drupal_execute() to drupal_submit_form().

parent a703b3ee
......@@ -213,7 +213,7 @@ function _batch_process() {
$set_changed = TRUE;
// If this batch was marked for progressive execution (e.g. forms submitted by
// drupal_execute()), initialize a timer to determine whether we need to
// drupal_form_submit()), initialize a timer to determine whether we need to
// proceed with the same batch phase when a processing time of 1 second has
// been exceeded.
if ($batch['progressive']) {
......
......@@ -38,7 +38,7 @@
* @endcode
*
* Forms can also be built and submitted programmatically without any user input
* using the drupal_execute() function.
* using the drupal_form_submit() function.
*
* For information on the format of the structured arrays used to define forms,
* and more detailed explanations of the Form API workflow, see the
......@@ -347,7 +347,7 @@ function form_set_cache($form_build_id, $form, $form_state) {
* form submission.
* @param ...
* Any additional arguments are passed on to the functions called by
* drupal_execute(), including the unique form constructor function.
* drupal_form_submit(), including the unique form constructor function.
* For example, the node_edit form requires that a node object be passed
* in here when it is called.
* For example:
......@@ -358,7 +358,7 @@ function form_set_cache($form_build_id, $form, $form_state) {
* $form_state['values']['mail'] = 'robouser@example.com';
* $form_state['values']['pass'] = 'password';
* $form_state['values']['op'] = t('Create new account');
* drupal_execute('user_register', $form_state);
* drupal_form_submit('user_register', $form_state);
*
* // Create a new node
* $form_state = array();
......@@ -368,9 +368,9 @@ function form_set_cache($form_build_id, $form, $form_state) {
* $form_state['values']['body'] = 'This is the body text!';
* $form_state['values']['name'] = 'robo-user';
* $form_state['values']['op'] = t('Save');
* drupal_execute('story_node_form', $form_state, (object)$node);
* drupal_form_submit('story_node_form', $form_state, (object)$node);
*/
function drupal_execute($form_id, &$form_state) {
function drupal_form_submit($form_id, &$form_state) {
if (!isset($form_state['args'])) {
$args = func_get_args();
array_shift($args);
......@@ -402,7 +402,7 @@ function drupal_execute($form_id, &$form_state) {
* @param ...
* Any additional arguments needed by the unique form constructor
* function. Generally, these are any arguments passed into the
* drupal_get_form() or drupal_execute() functions after the first
* drupal_get_form() or drupal_form_submit() functions after the first
* argument. If a module implements hook_forms(), it can examine
* these additional arguments and conditionally return different
* builder functions as well.
......@@ -511,7 +511,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
// If batches were set in the submit handlers, we process them now,
// possibly ending execution. We make sure we do not react to the batch
// that is already being processed (if a batch operation performs a
// drupal_execute).
// drupal_form_submit).
if ($batch =& batch_get() && !isset($batch['current_set'])) {
// The batch uses its own copies of $form and $form_state for
// late execution of submit handlers and post-batch redirection.
......@@ -529,7 +529,7 @@ function drupal_process_form($form_id, &$form, &$form_state) {
// bundle, and the $form_state['rebuild'] flag has not been set,
// we're finished and should redirect to a new destination page
// if one has been set (and a fresh, unpopulated copy of the form
// if one hasn't). If the form was called by drupal_execute(),
// if one hasn't). If the form was called by drupal_form_submit(),
// however, we'll skip this and let the calling function examine
// the resulting $form_state bundle itself.
if (!$form_state['programmed'] && empty($form_state['rebuild']) && empty($form_state['storage'])) {
......@@ -862,7 +862,7 @@ function form_execute_handlers($type, &$form, &$form_state) {
if (drupal_function_exists($function)) {
// Check to see 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 drupal_execute()).
// (for instance if a batch operation performs a drupal_form_submit()).
if ($type == 'submit' && ($batch =& batch_get()) && !isset($batch['current_set'])) {
// Some previous _submit handler has set a batch. We store the call
// in a special 'control' batch set, for execution at the correct
......
......@@ -338,7 +338,7 @@ function aggregator_form_opml_submit($form, &$form_state) {
$form_state['values']['title'] = $feed['title'];
$form_state['values']['url'] = $feed['url'];
drupal_execute('aggregator_form_feed', $form_state);
drupal_form_submit('aggregator_form_feed', $form_state);
}
$form_state['redirect'] = 'admin/content/aggregator';
......
......@@ -346,33 +346,33 @@ class FormsFormCleanIdFunctionalTest extends DrupalWebTestCase {
}
/**
* Test using drupal_execute in a batch.
* Test using drupal_form_submit in a batch.
*/
class FormAPITestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('Drupal Execute and Batch API'),
'description' => t('Tests the compatibility of drupal_execute and the Batch API'),
'description' => t('Tests the compatibility of drupal_form_submit and the Batch API'),
'group' => t('Form API'),
);
}
/**
* Check that we can run drupal_execute during a batch.
* Check that we can run drupal_form_submit during a batch.
*/
function testDrupalExecuteInBatch() {
function testDrupalFormSubmitInBatch() {
// Our test is going to modify the following variable.
variable_set('form_test_mock_submit', 'initial_state');
// This is a page that sets a batch, which calls drupal_execute, which
// This is a page that sets a batch, which calls drupal_form_submit, which
// modifies the variable we set up above.
$this->drupalGet('form_test/drupal_execute_batch_api');
$this->drupalGet('form_test/drupal_form_submit_batch_api');
// If the drupal_execute call executed correctly our test variable will be
// If the drupal_form_submit call executed correctly our test variable will be
// set to 'form_submitted'.
$this->assertEqual('form_submitted', variable_get('form_test_mock_submit', 'initial_state'), t('Check drupal_execute called submit handlers when running in a batch'));
$this->assertEqual('form_submitted', variable_get('form_test_mock_submit', 'initial_state'), t('Check drupal_form_submit called submit handlers when running in a batch'));
// Clean our variable up.
variable_del('form_test_mock_submit');
......
......@@ -51,9 +51,9 @@ function form_test_menu() {
'type' => MENU_CALLBACK,
);
$items['form_test/drupal_execute_batch_api'] = array(
'title' => 'BatchAPI Drupal_execute tests',
'page callback' => 'form_test_drupal_execute_batch_api',
$items['form_test/drupal_form_submit_batch_api'] = array(
'title' => 'BatchAPI Drupal_form_submit tests',
'page callback' => 'form_test_drupal_form_submit_batch_api',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
......@@ -226,17 +226,17 @@ function _form_test_tableselect_js_select_form($form_state, $action) {
}
/**
* Page callback for the batch/drupal_execute interaction test.
* Page callback for the batch/drupal_form_submit interaction test.
*
* When called without any arguments we set up a batch that calls
* form_test_batch_callback. That function will submit a form using
* drupal_execute using the values specified in this function.
* drupal_form_submit using the values specified in this function.
*
* The form's field test_value begins at 'initial_value', and is changed
* to 'form_submitted' when the form is submitted successfully. On
* completion this function is passed 'done' to complete the process.
*/
function form_test_drupal_execute_batch_api($arg = '') {
function form_test_drupal_form_submit_batch_api($arg = '') {
// If we're at the end of the batch process, return.
if ($arg == 'done') {
return t('Done');
......@@ -249,15 +249,15 @@ function form_test_drupal_execute_batch_api($arg = '') {
// Set the batch and process it.
batch_set($batch);
batch_process('form_test/drupal_execute_batch_api/done');
batch_process('form_test/drupal_form_submit_batch_api/done');
}
/**
* Submits form_test_mock_form using drupal_execute using the given $value.
* Submits form_test_mock_form using drupal_form_submit using the given $value.
*/
function form_test_batch_callback($value) {
$state['values']['test_value'] = $value;
drupal_execute('form_test_mock_form', $state);
drupal_form_submit('form_test_mock_form', $state);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment