Make WordPress Core

Opened 22 hours ago

Last modified 22 hours ago

#66142 new defect (bug)

Empty custom date/time fields are saved instead of remaining null in WordPress 7.1.1

Reported by: sanayasir Owned by:
Priority: normal Milestone: Awaiting Review
Component: Date/Time Version: 7.1.1
Severity: normal Keywords: needs-patch
Cc: Focuses:

Description

A regression appears to have been introduced in WordPress 7.1.1 involving the custom date and time format fields in Settings → General.

In WordPress 7.1, this behavior was resolved. However, after updating to WordPress 7.1.1, the issue appears again.

When the Custom date or time format option is selected and the custom input field is left blank, saving the General Settings still saves the empty value.

Ideally, when no custom date or time format has been entered, the corresponding setting should remain null rather than saving an empty custom value.

Steps to reproduce
Install WordPress 7.1.1.
Go to Settings → General.
Locate the Date Format or Time Format setting.
Select the Custom option.
Leave the custom date/time input field completely blank.
Click Save Changes.
Check the saved setting value.
Actual result

The settings are saved even though the custom date/time field is empty.

An empty custom value is stored instead of leaving the setting as null.

Expected result

If the custom date/time field is empty, WordPress should not save an empty custom value.

The corresponding setting should remain null until a valid custom date/time format is provided.

Regression

This behavior was resolved in WordPress 7.1, but appears to have regressed in WordPress 7.1.1.

Environment
WordPress: 7.1.1
Tested on: [Browser]
PHP: [PHP version]
Theme: [Theme]
Plugins: [Plugins / default installation]
Additional notes

The issue appears to be related to how the empty custom date/time fields are handled when the General Settings form is submitted.

The relevant handling is in wp-admin/options.php, where the custom date and time format values are processed before the options are updated.

Change History (1)

#1 @sanayasir
22 hours ago

  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.