After setting the default timezone in a installation profile or after refreshing the configuration page, there should be no timezone detection.

Files: 
CommentFileSizeAuthor
#11 1017020-install-timezone-detect.patch1.08 KBtim-e
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch 1017020-install-timezone-detect.patch. Unable to apply patch. See the log in the details link for more information. View
#7 install-timezone-detect-1017020-d7-7.patch1.32 KBsteinmb
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch install-timezone-detect-1017020-d7-7.patch. Unable to apply patch. See the log in the details link for more information. View
#6 install-timezone-detect-1017020-6.patch1.26 KBsteinmb
PASSED: [[SimpleTest]]: [MySQL] 37,016 pass(es). View
#3 install-timezone-detect-1017020-3.patch1.28 KBDavid_Rothstein
PASSED: [[SimpleTest]]: [MySQL] 31,554 pass(es). View
#1 install-timezone-detect-1017020-1.patch1.23 KBDavid_Rothstein
PASSED: [[SimpleTest]]: [MySQL] 31,524 pass(es). View

Comments

David_Rothstein’s picture

Version: 7.0 » 7.x-dev
Status: Active » Needs review
FileSize
1.23 KB
PASSED: [[SimpleTest]]: [MySQL] 31,524 pass(es). View

Yup, that makes sense. And it's basically what system.module already does for the timezone selection on user account pages.

How about this patch?

Jan_vStone’s picture

Seems to fix the issue when you use variable_set('date_default_timezone') but not when using the _form_install_configure_form_alter hook. For that to work, the check if a default timezone has been selected should probably be done in the timezone.js javascript file.

David_Rothstein’s picture

FileSize
1.28 KB
PASSED: [[SimpleTest]]: [MySQL] 31,554 pass(es). View

I don't think there's any simple way for the timezone.js code to know who set the form element's default value or what their intention was.

However, we can switch to using #attached to add the JavaScript to the page, so that someone who wants to remove this in hook_form_alter() can do that more easily. That is done in the attached patch.

Jan_vStone’s picture

The solution/patch in #3 works with following code in form_alter (for future reference)

function PROFILE_NAME_form_install_configure_form_alter(&$form, $form_state) {
  $form['server_settings']['date_default_timezone']['#default_value'] = 'Europe/Brussels';

  $key = array_search('misc/timezone.js', $form['server_settings']['date_default_timezone']['#attached']['js']);
  if ($key !== FALSE) {
    unset($form['server_settings']['date_default_timezone']['#attached']['js'][$key]);
  }
}
nod_’s picture

Version: 7.x-dev » 8.x-dev
steinmb’s picture

FileSize
1.26 KB
PASSED: [[SimpleTest]]: [MySQL] 37,016 pass(es). View

Time to re-roll patch.

steinmb’s picture

FileSize
1.32 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch install-timezone-detect-1017020-d7-7.patch. Unable to apply patch. See the log in the details link for more information. View

Drupal 7 backport. Tested with hook_form_alter() in a install profile and seemed to work perfect.

Status: Needs review » Needs work

The last submitted patch, install-timezone-detect-1017020-d7-7.patch, failed testing.

nod_’s picture

Status: Needs work » Needs review
cweagans’s picture

tim-e’s picture

FileSize
1.08 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch 1017020-install-timezone-detect.patch. Unable to apply patch. See the log in the details link for more information. View

Patch for D7.

Status: Needs review » Needs work

The last submitted patch, 1017020-install-timezone-detect.patch, failed testing.

nod_’s picture

Status: Needs work » Needs review

Newt time, please end the name of your current patch with "do-no-test.patch" so that it won't mess up things, thanks :)

tim-e’s picture

oh, is that because this issue is 8.x ?

nod_’s picture

yes :)

steinmb’s picture

@tim-e Why did you remove comments in the D7 patch in #7? Do we not need them?

tim-e’s picture

The patch in #7 didnt work for me since _install_configure_form() reinitialises $form_state['server_settings'] and so we lose the ['#attached'] element and timezone.js is still loaded regardless.

thyssimonis’s picture

If you unset the #attributes the class timezone-detect is removed from the select and no timezone detecting will be run.

This wil work in D7

/**
 * Implements hook_form_FORM_ID_alter().
 */
function PROFILE_NAME_form_install_configure_form_alter(&$form, $form_state) {
  $form['server_settings']['date_default_timezone']['#default_value'] = 'Europe/Amsterdam';
  unset($form['server_settings']['date_default_timezone']['#attributes']);
}

Status: Needs review » Needs work

The last submitted patch, 11: 1017020-install-timezone-detect.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.