Opened 7 weeks ago
Last modified 6 weeks 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-testing has-patch has-unit-tests close |
| 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.
Attachments (1)
Change History (6)
This ticket was mentioned in PR #13648 on WordPress/wordpress-develop by @irozum.
7 weeks ago
#3
- Keywords has-patch has-unit-tests added; needs-patch removed
#4
@
7 weeks ago
Test Report
I tested this ticket using WordPress Playground and was able to reproduce the issue.
I also tested the proposed patch, but the issue still persists in my test environment.
Steps tested
- Navigated to Settings → General.
- Selected the Custom option under Date Format.
- Left the custom format field completely empty.
- Clicked Save Changes.
Actual Result
The empty custom date format is still saved after applying the patch.
Expected Result
When the Custom option is selected but the custom format field is left empty, the empty custom value should not be saved.
Test Result
The issue is still reproducible with the current patch.
Tested using WordPress Playground.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
When "Custom" is selected for the Date Format or Time Format on Settings → General and the custom text field is left blank, WordPress saves the empty value as the option instead of leaving the existing setting untouched, so a user who accidentally clears the custom field and saves loses their previously configured format.
The fix extracts the resolution logic into a new small, unit-testable function,
wp_get_submitted_date_time_format()inwp-admin/includes/misc.php, which returnsnullwhen "Custom" is selected with an empty value.wp-admin/options.phpnow uses that return value to skip savingdate_format/time_formatentirely in that case, leaving the previously stored option value in place, rather than overwriting it with an empty string.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Implementation, tests, and PR description. Reviewed by Igor Rozum.