Commit 1fe90cba authored by Dries's avatar Dries
Browse files

- Patch #146667 by Eaton: correct builder argument ordering, eliminate redundant arguments

parent 712c5758
......@@ -1742,15 +1742,15 @@ function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer
* @return
* All JavaScript code segments and includes for the scope as HTML tags.
*/
function drupal_get_js($scope = 'header', $javascript = NULL) {
function drupal_get_js($scope = 'header', $javascript = NULL) {
if (!isset($javascript)) {
$javascript = drupal_add_js(NULL, NULL, $scope);
}
if (count($javascript) < 1) {
return '';
}
}
$output = '';
$preprocessed = '';
$no_preprocess = array('core' => '', 'module' => '', 'theme' => '');
......@@ -1760,7 +1760,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
$is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
foreach ($javascript as $type => $data) {
if (!$data) continue;
switch ($type) {
......@@ -1776,27 +1776,27 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
// If JS preprocessing is off, we still need to output the scripts.
// Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones.
foreach ($data as $path => $info) {
if (!$info['preprocess'] || !$is_writable || !$preprocess_js) {
if (!$info['preprocess'] || !$is_writable || !$preprocess_js) {
$no_preprocess[$type] .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .' src="'. base_path() . $path . ($info['cache'] ? '' : '?'. time()) ."\"></script>\n";
}
else {
else {
$files[$path] = $info;
}
}
}
}
// Aggregate any remaining JS files that haven't already been output.
if ($is_writable && $preprocess_js && count($files) > 0) {
if ($is_writable && $preprocess_js && count($files) > 0) {
$filename = md5(serialize($files)) .'.js';
$preprocess_file = drupal_build_js_cache($files, $filename);
$preprocessed .= '<script type="text/javascript" src="'. base_path() . $preprocess_file .'"></script>'. "\n";
}
// Keep the order of JS files consistent as some are preprocessed and others are not.
// Make sure any inline or JS setting variables appear last after libraries have loaded.
$output = $preprocessed . implode('', $no_preprocess) . $output;
return $output;
}
......@@ -1818,9 +1818,9 @@ function drupal_build_js_cache($files, $filename) {
file_check_directory($jspath, FILE_CREATE_DIRECTORY);
if (!file_exists($jspath .'/'. $filename)) {
// Build aggregate JS file.
foreach ($files as $path => $info) {
if ($info['preprocess']) {
// Build aggregate JS file.
foreach ($files as $path => $info) {
if ($info['preprocess']) {
// Append a ';' after each JS file to prevent them from running together.
$contents .= _drupal_compress_js(file_get_contents($path). ';');
}
......@@ -1858,8 +1858,8 @@ function _drupal_compress_js($script) {
$script = _packer_apply($script, $regexps, TRUE);
return $script;
}
}
/**
* Multi-regexp replacements.
*
......@@ -1887,7 +1887,7 @@ function _packer_apply($script, $regexps, $escape = FALSE) {
// Count the number of matching groups (including the whole).
$length = 1 + preg_match_all('/(?<!\\\\)\((?!\?)/', $expression, $out);
// Treat only strings $replacement
if (is_string($replacement)) {
// Does the pattern deal with sub-expressions?
......@@ -1918,9 +1918,9 @@ function _packer_apply($script, $regexps, $escape = FALSE) {
$_regexps[] = array('/^$/', $replacement, $length);
}
}
// Execute the global replacement
// Build one mega-regexp out of the smaller ones.
$regexp = '/';
foreach ($_regexps as $_regexp) {
......@@ -1928,7 +1928,7 @@ function _packer_apply($script, $regexps, $escape = FALSE) {
$regexp .= '(' . substr($expression, 1, -1) . ')|';
}
$regexp = substr($regexp, 0, -1) . '/';
// In order to simplify the regexps that look e.g. for quoted strings, we
// remove all escaped characters (such as \' or \") from the data. Then, we
// put them back as they were.
......@@ -1983,7 +1983,7 @@ function _packer_escape_char($match, $return = FALSE) {
$_escaped[] = $match[1];
return '\\';
}
}
}
/**
* Helper function for _packer_apply().
......@@ -2003,12 +2003,12 @@ function _packer_replacement($arguments, $regexps = NULL, $escape = NULL) {
if (empty($arguments)) {
return '';
}
$i = 1; $j = 0;
// Loop through the regexps
while (isset($_regexps[$j])) {
list($expression, $replacement, $length) = $_regexps[$j++];
// Do we have a result?
if (isset($arguments[$i]) && ($arguments[$i] != '')) {
if (is_array($replacement) && isset($replacement['fn'])) {
......@@ -2043,7 +2043,7 @@ function _packer_unescape_char($match, $escaped = NULL) {
else {
return '\\'. array_shift($_escaped);
}
}
}
/**
* Helper function for _packer_replacement().
......
......@@ -75,6 +75,10 @@ function drupal_get_form($form_id) {
// to build it from scratch.
if (!isset($form)) {
$form_state['post'] = $_POST;
array_shift($args);
array_unshift($args, $form_state);
array_unshift($args, $form_id);
$form = call_user_func_array('drupal_retrieve_form', $args);
$form_build_id = 'form-'. md5(mt_rand());
$form['#build_id'] = $form_build_id;
......@@ -109,7 +113,9 @@ function drupal_get_form($form_id) {
// other variables passed into drupal_get_form().
if (!empty($form_state['rebuild']) || !empty($form_state['storage'])) {
$args[] = $form_state;
array_shift($args);
array_unshift($args, $form_state);
array_unshift($args, $form_id);
$form = call_user_func_array('drupal_retrieve_form', $args);
// We need a new build_id for the new version of the form.
......@@ -182,8 +188,7 @@ function drupal_execute($form_id, &$form_state) {
// the $form_state to be the last parameter, while drupal_execute()
// always takes it in as the second parameter.
$args = array_slice($args, 3);
array_unshift($args, $form_id);
$args[] = $form_state;
$args[1] = $form_state;
$form = call_user_func_array('drupal_retrieve_form', $args);
$form['#post'] = $form_state['values'];
......@@ -200,10 +205,12 @@ function drupal_execute($form_id, &$form_state) {
* Modules that need to generate the same form (or very similar forms)
* using different $form_ids can implement hook_forms(), which maps
* different $form_id values to the proper form constructor function.
* @param $form_state
* A keyed array containing the current state of the form.
* @param ...
* Any additional arguments needed by the form constructor function.
*/
function drupal_retrieve_form($form_id) {
function drupal_retrieve_form($form_id, &$form_state) {
static $forms;
// We save two copies of the incoming arguments: one for modules to use
......@@ -214,6 +221,9 @@ function drupal_retrieve_form($form_id) {
$args = func_get_args();
$saved_args = $args;
array_shift($args);
if (isset($form_state)) {
array_shift($args);
}
// We first check to see if there's a function named after the $form_id.
// If there is, we simply pass the arguments on to it to get the form.
......@@ -240,6 +250,9 @@ function drupal_retrieve_form($form_id) {
$callback = $form_definition['callback'];
}
}
array_unshift($args, $form_state);
// If $callback was returned by a hook_forms() implementation, call it.
// Otherwise, call the function named after the form id.
$form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);
......@@ -613,7 +626,7 @@ function form_execute_handlers($type, &$form, &$form_state) {
$batch['sets'][] = array('form_submit' => $function);
}
else {
$function($form, $form_state, $form_state['values']);
$function($form, $form_state);
}
$return = TRUE;
}
......@@ -742,7 +755,7 @@ function form_builder($form_id, $form, &$form_state) {
// after normal input parsing has been completed.
if (isset($form['#after_build']) && !isset($form['#after_build_done'])) {
foreach ($form['#after_build'] as $function) {
$form = $function($form, $form_state['values'], $form_state);
$form = $function($form, $form_state);
$form['#after_build_done'] = TRUE;
}
}
......@@ -918,7 +931,7 @@ function _form_builder_ie_cleanup($form, &$form_state) {
*
* Specifically, if $form['#parents'] is array('foo', 'bar')
* and $value is 'baz' then this function will make
* $form_values['foo']['bar'] to be 'baz'.
* $form_state['values']['foo']['bar'] to be 'baz'.
*
* @param $form
* The form item. Keys used: #parents, #value
......@@ -933,7 +946,7 @@ function form_set_value($form, $value, &$form_state) {
* Helper function for form_set_value().
*
* We iterate over $parents and create nested arrays for them
* in $form_values if needed. Then we insert the value into
* in $form_state['values'] if needed. Then we insert the value into
* the right array.
*/
function _form_set_value(&$form_values, $form, $parents, $value) {
......
......@@ -81,27 +81,27 @@ function theme_locale_languages_overview_form($form) {
/**
* Process language overview form submissions, updating existing languages.
*/
function locale_languages_overview_form_submit($form, &$form_state, $form_values) {
function locale_languages_overview_form_submit($form, &$form_state) {
$languages = language_list();
$enabled_count = 0;
foreach ($languages as $langcode => $language) {
if ($form_values['site_default'] == $langcode) {
if ($form_state['values']['site_default'] == $langcode) {
// Automatically enable the default language.
$form_values['enabled'][$langcode] = 1;
$form_state['values']['enabled'][$langcode] = 1;
}
if ($form_values['enabled'][$langcode]) {
if ($form_state['values']['enabled'][$langcode]) {
$enabled_count++;
$language->enabled = 1;
}
else {
$language->enabled = 0;
}
$language->weight = $form_values['weight'][$langcode];
$language->weight = $form_state['values']['weight'][$langcode];
db_query("UPDATE {languages} SET enabled = %d, weight = %d WHERE language = '%s'", $language->enabled, $language->weight, $langcode);
$languages[$langcode] = $language;
}
drupal_set_message(t('Configuration saved.'));
variable_set('language_default', $languages[$form_values['site_default']]);
variable_set('language_default', $languages[$form_state['values']['site_default']]);
variable_set('language_count', $enabled_count);
// Changing the language settings impacts the interface.
......@@ -175,7 +175,7 @@ function locale_languages_custom_form() {
* @param $langcode
* Language code of the language to edit.
*/
function locale_languages_edit_form($langcode) {
function locale_languages_edit_form(&$form_state, $langcode) {
if ($language = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $langcode))) {
$form = array();
_locale_languages_common_controls($form, $language);
......@@ -265,14 +265,14 @@ function _locale_languages_common_controls(&$form, $language = NULL) {
/**
* Validate the language addition form.
*/
function locale_languages_predefined_form_validate($form, &$form_state, $form_values) {
$langcode = $form_values['langcode'];
function locale_languages_predefined_form_validate($form, &$form_state) {
$langcode = $form_state['values']['langcode'];
if ($duplicate = db_num_rows(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode)) != 0) {
form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_values['name'], '%code' => $langcode)));
form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode)));
}
if (!isset($form_values['name'])) {
if (!isset($form_state['values']['name'])) {
// Predefined language selection.
$predefined = _locale_get_predefined_list();
if (!isset($predefined[$langcode])) {
......@@ -281,19 +281,19 @@ function locale_languages_predefined_form_validate($form, &$form_state, $form_va
}
else {
// Reuse the editing form validation routine if we add a custom language.
locale_languages_edit_form_validate($form_values, $form, $form_state);
locale_languages_edit_form_validate($form_state['values'], $form, $form_state);
}
}
/**
* Process the language addition form submission.
*/
function locale_languages_predefined_form_submit($form, &$form_state, $form_values) {
$langcode = $form_values['langcode'];
if (isset($form_values['name'])) {
function locale_languages_predefined_form_submit($form, &$form_state) {
$langcode = $form_state['values']['langcode'];
if (isset($form_state['values']['name'])) {
// Custom language form.
locale_add_language($langcode, $form_values['name'], $form_values['native'], $form_values['direction'], $form_values['domain'], $form_values['prefix']);
drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($form_values['name']), '@locale-help' => url('admin/help/locale'))));
locale_add_language($langcode, $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['direction'], $form_state['values']['domain'], $form_state['values']['prefix']);
drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($form_state['values']['name']), '@locale-help' => url('admin/help/locale'))));
}
else {
// Predefined language selection.
......@@ -315,31 +315,31 @@ function locale_languages_predefined_form_submit($form, &$form_state, $form_valu
/**
* Validate the language editing form. Reused for custom language addition too.
*/
function locale_languages_edit_form_validate($form, &$form_state, $form_values) {
if (!empty($form_values['domain']) && !empty($form_values['prefix'])) {
function locale_languages_edit_form_validate($form, &$form_state) {
if (!empty($form_state['values']['domain']) && !empty($form_state['values']['prefix'])) {
form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.'));
}
if (!empty($form_values['domain']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE domain = '%s' AND language != '%s'", $form_values['domain'], $form_values['langcode']))) {
form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_values['domain'], '%language' => $duplicate->language)));
if (!empty($form_state['values']['domain']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE domain = '%s' AND language != '%s'", $form_state['values']['domain'], $form_state['values']['langcode']))) {
form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_state['values']['domain'], '%language' => $duplicate->language)));
}
if (empty($form_values['prefix']) && language_default('language') != $form_values['langcode'] && empty($form_values['domain'])) {
if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['langcode'] && empty($form_state['values']['domain'])) {
form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.'));
}
if (!empty($form_values['prefix']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE prefix = '%s' AND language != '%s'", $form_values['prefix'], $form_values['langcode']))) {
form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array('%prefix' => $form_values['prefix'], '%language' => $duplicate->language)));
if (!empty($form_state['values']['prefix']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE prefix = '%s' AND language != '%s'", $form_state['values']['prefix'], $form_state['values']['langcode']))) {
form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array('%prefix' => $form_state['values']['prefix'], '%language' => $duplicate->language)));
}
}
/**
* Process the language editing form submission.
*/
function locale_languages_edit_form_submit($form, &$form_state, $form_values) {
db_query("UPDATE {languages} SET name = '%s', native = '%s', domain = '%s', prefix = '%s', direction = %d WHERE language = '%s'", $form_values['name'], $form_values['native'], $form_values['domain'], $form_values['prefix'], $form_values['direction'], $form_values['langcode']);
function locale_languages_edit_form_submit($form, &$form_state) {
db_query("UPDATE {languages} SET name = '%s', native = '%s', domain = '%s', prefix = '%s', direction = %d WHERE language = '%s'", $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['domain'], $form_state['values']['prefix'], $form_state['values']['direction'], $form_state['values']['langcode']);
$default = language_default();
if ($default->language == $form_values['langcode']) {
if ($default->language == $form_state['values']['langcode']) {
$properties = array('name', 'native', 'direction', 'enabled', 'plurals', 'formula', 'domain', 'prefix', 'weight');
foreach ($properties as $keyname) {
$default->$keyname = $form_values[$keyname];
$default->$keyname = $form_state['values'][$keyname];
}
variable_set('language_default', $default);
}
......@@ -358,7 +358,7 @@ function locale_languages_edit_form_submit($form, &$form_state, $form_values) {
/**
* User interface for the language deletion confirmation screen.
*/
function locale_languages_delete_form($langcode) {
function locale_languages_delete_form(&$form_state, $langcode) {
// Do not allow deletion of English locale.
if ($langcode == 'en') {
......@@ -386,13 +386,13 @@ function locale_languages_delete_form($langcode) {
/**
* Process language deletion submissions.
*/
function locale_languages_delete_form_submit($form, &$form_state, $form_values) {
function locale_languages_delete_form_submit($form, &$form_state) {
$languages = language_list();
if (isset($languages[$form_values['langcode']])) {
db_query("DELETE FROM {languages} WHERE language = '%s'", $form_values['langcode']);
db_query("DELETE FROM {locales_target} WHERE language = '%s'", $form_values['langcode']);
db_query("UPDATE {node} SET language = '' WHERE language = '%s'", $form_values['langcode']);
$variables = array('%locale' => $languages[$form_values['langcode']]->name);
if (isset($languages[$form_state['values']['langcode']])) {
db_query("DELETE FROM {languages} WHERE language = '%s'", $form_state['values']['langcode']);
db_query("DELETE FROM {locales_target} WHERE language = '%s'", $form_state['values']['langcode']);
db_query("UPDATE {node} SET language = '' WHERE language = '%s'", $form_state['values']['langcode']);
$variables = array('%locale' => $languages[$form_state['values']['langcode']]->name);
drupal_set_message(t('The language %locale has been removed.', $variables));
watchdog('locale', 'The language %locale has been removed.', $variables);
}
......@@ -437,8 +437,8 @@ function locale_languages_configure_form() {
/**
* Submit function for language negotiation settings.
*/
function locale_languages_configure_form_submit($form, &$form_state, $form_values) {
variable_set('language_negotiation', $form_values['language_negotiation']);
function locale_languages_configure_form_submit($form, &$form_state) {
variable_set('language_negotiation', $form_state['values']['language_negotiation']);
drupal_set_message(t('Language negotiation configuration saved.'));
$form_state['redirect'] = 'admin/settings/language';
return;
......@@ -610,13 +610,13 @@ function locale_translate_import_form() {
/**
* Process the locale import form submission.
*/
function locale_translate_import_form_submit($form, &$form_state, $form_values) {
function locale_translate_import_form_submit($form, &$form_state) {
// Ensure we have the file uploaded
if ($file = file_save_upload('file')) {
// Add language, if not yet supported
$languages = language_list('language', TRUE);
$langcode = $form_values['langcode'];
$langcode = $form_state['values']['langcode'];
if (!isset($languages[$langcode])) {
$predefined = _locale_get_predefined_list();
locale_add_language($langcode);
......@@ -624,7 +624,7 @@ function locale_translate_import_form_submit($form, &$form_state, $form_values)
}
// Now import strings into the language
if ($ret = _locale_import_po($file, $langcode, $form_values['mode'], $form_values['group']) == FALSE) {
if ($ret = _locale_import_po($file, $langcode, $form_state['values']['mode'], $form_state['values']['group']) == FALSE) {
$variables = array('%filename' => $file->filename);
drupal_set_message(t('The translation import of %filename failed.', $variables), 'error');
watchdog('locale', 'The translation import of %filename failed.', $variables, WATCHDOG_ERROR);
......@@ -669,7 +669,7 @@ function locale_translate_export_screen() {
* @param $names
* An associate array with localized language names
*/
function locale_translate_export_po_form($names) {
function locale_translate_export_po_form(&$form_state, $names) {
$form['export'] = array('#type' => 'fieldset',
'#title' => t('Export translation'),
'#collapsible' => TRUE,
......@@ -713,9 +713,9 @@ function locale_translate_export_pot_form() {
/**
* Process a translation (or template) export form submission.
*/
function locale_translate_export_po_form_submit($form, &$form_state, $form_values) {
function locale_translate_export_po_form_submit($form, &$form_state) {
// If template is required, language code is not given.
_locale_export_po(isset($form_values['langcode']) ? $form_values['langcode'] : NULL, $form_values['group']);
_locale_export_po(isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : NULL, $form_state['values']['group']);
}
/**
* @} End of "locale-translate-export"
......@@ -729,7 +729,7 @@ function locale_translate_export_po_form_submit($form, &$form_state, $form_value
/**
* User interface for string editing.
*/
function locale_translate_edit_form($lid) {
function locale_translate_edit_form(&$form_state, $lid) {
$languages = language_list();
unset($languages['en']);
......@@ -782,9 +782,9 @@ function locale_translate_edit_form($lid) {
* Process string editing form submissions.
* Saves all translations of one string submitted from a form.
*/
function locale_translate_edit_form_submit($form, &$form_state, $form_values) {
$lid = $form_values['lid'];
foreach ($form_values['translations'] as $key => $value) {
function locale_translate_edit_form_submit($form, &$form_state) {
$lid = $form_state['values']['lid'];
foreach ($form_state['values']['translations'] as $key => $value) {
$trans = db_fetch_object(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key));
if (isset($trans->translation)) {
db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $value, $lid, $key);
......
......@@ -208,7 +208,7 @@ function install_change_settings($profile = 'default', $install_locale = '') {
/**
* Form API array definition for install_settings.
*/
function install_settings_form($profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path) {
function install_settings_form(&$form_state, $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path) {
if (empty($db_host)) {
$db_host = 'localhost';
}
......@@ -335,9 +335,9 @@ function install_settings_form($profile, $install_locale, $settings_file, $db_ur
/**
* Form API validate for install_settings form.
*/
function install_settings_form_validate($form, &$form_state, $form_values) {
function install_settings_form_validate($form, &$form_state) {
global $db_url;
_install_settings_form_validate($form_values['db_prefix'], $form_values['db_type'], $form_values['db_user'], $form_values['db_pass'], $form_values['db_host'], $form_values['db_port'], $form_values['db_path'], $form_values['settings_file'], $form_state, $form);
_install_settings_form_validate($form_state['values']['db_prefix'], $form_state['values']['db_type'], $form_state['values']['db_user'], $form_state['values']['db_pass'], $form_state['values']['db_host'], $form_state['values']['db_port'], $form_state['values']['db_path'], $form_state['values']['settings_file'], $form_state, $form);
}
/**
......@@ -387,16 +387,16 @@ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pas
/**
* Form API submit for install_settings form.
*/
function install_settings_form_submit($form, &$form_state, $form_values) {
function install_settings_form_submit($form, &$form_state) {
global $profile, $install_locale;
// Update global settings array and save
$settings['db_url'] = array(
'value' => $form_values['_db_url'],
'value' => $form_state['values']['_db_url'],
'required' => TRUE,
);
$settings['db_prefix'] = array(
'value' => $form_values['db_prefix'],
'value' => $form_state['values']['db_prefix'],
'required' => TRUE,
);
drupal_rewrite_settings($settings);
......@@ -444,7 +444,7 @@ function install_select_profile() {
}
}
function install_select_profile_form($profiles) {
function install_select_profile_form(&$form_state, $profiles) {
foreach ($profiles as $profile) {
include_once($profile->filename);
// Load profile details.
......@@ -531,7 +531,7 @@ function install_select_locale($profilename) {
}
}
function install_select_locale_form($locales) {
function install_select_locale_form(&$form_state, $locales) {
include_once './includes/locale.inc';
$languages = _locale_get_predefined_list();
foreach ($locales as $locale) {
......@@ -622,7 +622,7 @@ function install_tasks($profile, $task) {
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form = drupal_retrieve_form('install_configure_form');
$form = drupal_retrieve_form('install_configure_form', $form_state);
$form_build_id = md5(mt_rand());
$form['#build_id'] = $form_build_id;
drupal_prepare_form('install_configure_form', $form, $form_state);
......@@ -926,36 +926,42 @@ function install_configure_form() {
return $form;
}
function install_configure_form_validate($form, &$form_state, $form_values) {
if ($error = user_validate_name($form_values['account']['name'])) {
function install_configure_form_validate($form, &$form_state) {
if ($error = user_validate_name($form_state['values']['account']['name'])) {
form_error($form['admin_account']['account']['name'], $error);
}
if ($error = user_validate_mail($form_values['account']['mail'])) {
if ($error = user_validate_mail($form_state['values']['account']['mail'])) {
form_error($form['admin_account']['account']['mail'], $error);
}
if ($error = user_validate_mail($form_values['site_mail'])) {
if ($error = user_validate_mail($form_state['values']['site_mail'])) {
form_error($form['site_information']['site_mail'], $error);
}
}
function install_configure_form_submit($form, &$form_state, $form_values) {
function install_configure_form_submit($form, &$form_state) {
global $user;
variable_set('site_name', $form_values['site_name']);
variable_set('site_mail', $form_values['site_mail']);
variable_set('date_default_timezone', $form_values['date_default_timezone']);
variable_set('site_name', $form_state['values']['site_name']);
variable_set('site_mail', $form_state['values']['site_mail']);
variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);
// Turn this off temporarily so that we can pass a password through.
variable_set('user_email_verification', FALSE);
user_register_submit($form, $form_state, $form_values['account']);
$form_state['old_values'] = $form_state['values'];
$form_state['values'] = $form_state['values']['account'];
user_register_submit($form, $form_state);
$form_state['values'] = $form_state['old_values'];
unset($form_state['old_values']);
variable_set('user_email_verification', TRUE);
if (isset($form_values['clean_url'])) {
variable_set('clean_url', $form_values['clean_url']);
if (isset($form_state['values']['clean_url'])) {
variable_set('clean_url', $form_state['values']['clean_url']);
}
// The user is now logged in, but has no session ID yet, which
// would be required later in the request, so remember it.
$user->sid = session_id();
return 'finished';
$form_state['redirect'] = 'finished';
}
install_main();
......@@ -50,7 +50,7 @@ Drupal.redirectFormButton = function (uri, button, handler) {
// Restore form submission
button.form.action = action;
button.form.target = target;
// Get response from iframe body
try {
response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML;
......@@ -64,7 +64,7 @@ Drupal.redirectFormButton = function (uri, button, handler) {