Problem/Motivation

On PHP 8.4, the following deprecation notice is logged every time a user visits a page that triggers the timezone auto-detection AJAX request (e.g. /user/register with "Users may set their own time zone" enabled):

Deprecated function: timezone_name_from_abbr(): Passing null to parameter #3 ($isDST) of
type int is deprecated in
Drupal\system\Controller\TimezoneController->getTimezone()
(line 49 of web/core/modules/system/src/Controller/TimezoneController.php)

The deprecation does not crash the page, but it fills the database log with noise and will become a fatal error in PHP 9.

Steps to reproduce

Prerequisites

  1. Install a clean Drupal 11.3.x site using the Standard installation profile, running on PHP 8.4.

Configure the site

  1. Go to Administration → Configuration → Regional and language → Regional settings (/admin/config/regional/settings) and set "Users may set their own time zone" to "Users may set their own time zone". Save.

    Regional settings — Users may set their own time zone
  2. Go to Administration → Configuration → People → Account settings (/admin/config/people/accounts) and enable visitor registration under Who can register accounts. Save.

    Account settings — visitor registration enabled

Trigger the bug

  1. If you are not physically located in India, temporarily change your OS timezone so that Intl.DateTimeFormat().resolvedOptions().timeZone returns Asia/Kolkata (macOS may report this as the legacy alias Asia/Calcutta — both refer to the same timezone). On macOS: System Settings → General → Date & Time → disable "Set time zone automatically using your current location" → set Closest city to "Kolkata - India". The Time zone field will update to India Standard Time.

    This is the key condition: India Standard Time (UTC+5:30) has no Daylight Saving Time, which causes timezone.js to send an empty string for the DST parameter. Most Western timezones observe DST and send 0 or 1, which matches the route constraint and avoids the bug.

    macOS Date & Time — India Standard Time / Kolkata - India
  2. Open a browser (or a new private window) and visit /user/register.
  3. Go to Administration → Reports → Recent log messages (/admin/reports/dblog), filter by type php. The deprecation notice will appear. It is triggered because timezone.js sends a request to /system/timezone/0/19800/ with an empty last segment for {is_daylight_saving_time}, which does not match the route constraint \-1|0|1, so Symfony falls back to the route default NULL. Click the entry to see the full message and stack trace.

Proposed resolution

The cleanest fix is a single-line change in core/modules/system/system.routing.yml: set the default value of is_daylight_saving_time to -1 instead of NULL.

-1 is the documented sentinel value for timezone_name_from_abbr() meaning "do not consider DST". The same pattern is already used for the offset parameter in the same route (offset: -1). Changing the default means the controller always receives a valid int whether the URL segment is present or absent.

 system.timezone:
   defaults:
     offset: -1
-    is_daylight_saving_time: NULL
+    is_daylight_saving_time: -1

This also makes core/misc/timezone.js semantically correct without any JS change: the empty string it sends for no-DST timezones falls through to the default, which will now be -1 rather than NULL.

Optional hardening — also fix core/misc/timezone.js to send -1 explicitly instead of '', so the URL segment is always present and valid:

- var isDaylightSavingTime = '';
+ var isDaylightSavingTime = -1;

Remaining tasks

  • Confirm the fix on Drupal 10.x (likely affected on PHP 8.4 as well)
  • Add a regression test

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

None required.

PS: AI was used to review and re-word my original description

Issue fork drupal-3585397

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

marcelovani created an issue. See original summary.

quietone’s picture

Version: 11.3.x-dev » main
Issue tags: -PHP 8.4

The issue summary reads like it was generated using an AI tool. The policy on the use of AI when contributing to Drupal includes that the use of AI must be disclosed. I suggest reading that to be aware of the expectations of the Drupal community and the consequences for violations of the policy.

Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.

marcelovani’s picture

Version: main » 11.3.x-dev

Updated the branch. Yes, I used AI to review my personal summary but I think it looks great.

marcelovani’s picture

Version: 11.3.x-dev » main

Sorry, I read it incorrectly about the version, reverting.

marcelovani’s picture

Issue summary: View changes
ishani patel’s picture

Assigned: Unassigned » ishani patel

ishani patel’s picture

Assigned: ishani patel » Unassigned

Hello,
I've raised MR, Kindly review it.

Thank you!

marcelovani’s picture

StatusFileSize
new330.9 KB

Code looks good, but you need to update the automated tests too.

Automated tests failed

Ps: I was thinking in ways to test the specific scenario that requires the system to be running in a location that does not have BST, but I am not sure if that is possible to automate.

marcelovani’s picture

Status: Active » Needs work

sivaji_ganesh_jojodae made their first commit to this issue’s fork.

sivaji_ganesh_jojodae’s picture

Status: Needs work » Needs review

I've updated the automated test.

marcelovani’s picture

Looks good to me

smustgrave’s picture

Status: Needs review » Needs work

Think this needs more work. TimezoneController::getTimezone() $is_daylight_saving_time defaults to NULL, so should it default to -1

marcelovani’s picture

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.27 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

marcelovani’s picture

Status: Needs work » Needs review

Fixed PHPCS issue

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe feedback for this one has been addressed

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Added comments to the MR.

marcelovani’s picture

Status: Needs work » Needs review