Problem/Motivation

In User::preSave() we do:

    $config = \Drupal::config('system.date');
    if ($config->get('timezone.user.configurable') && !$this->getTimeZone() && !$config->get('timezone.user.default')) {
      $this->set('timezone', $config->get('timezone.default'));
    }

Steps to reproduce

But $config->get('timezone.user.default') is not a boolean - it is a tri-state switch using the \Drupal\user\UserInterface::TIMEZONE_DEFAULT, \Drupal\user\UserInterface::TIMEZONE_EMPTY and \Drupal\user\UserInterface::TIMEZONE_SELECT constants so let's use them here.

Proposed resolution

Use the constant in the if

Remaining tasks

User interface changes

None

Introduced terminology

N/a

API changes

N/a

Data model changes

None

Release notes snippet

N/a

Issue fork drupal-3549587

Command icon 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

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review

I've gone for a loose comparison to match the existing if.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems straight forward enough!

astonvictor’s picture

thanks for the fix
+1 RTBC

catch’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 11.3.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • catch committed be2bb335 on 11.3.x
    Issue #3549587 by alexpott: Use \Drupal\user\UserInterface::...

  • catch committed 594d05dc on 11.x
    Issue #3549587 by alexpott: Use \Drupal\user\UserInterface::...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.