forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Options, Meta APIs: Prevent saving of invalid timezones.
Prevent the saving of invalid timezone string in to the database on the options pages. If an invalid timezone is submitted it is ignored and the setting remains unchanged. This prevents a warning or fatal (depending on the PHP version) from being thrown by an invalid timezone setting on the Settings > General page. Props ankit-k-gupta, costdev, huzaifaalmesbah, mrinal013, nicolefurlan, oglekler. Fixes #58814. git-svn-id: https://develop.svn.wordpress.org/trunk@56949 602fd350-edb4-49c9-b593-d223f7449a82
- Loading branch information
1 parent
6802179
commit c626e63
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { test, expect } from '@wordpress/e2e-test-utils-playwright'; | ||
|
||
test.describe( 'Settings -> General', () => { | ||
const invalidTimezones = [ '', '0', 'Barry/Gary' ]; | ||
|
||
for ( const invalidTimezone of invalidTimezones ) { | ||
test( `Does not allow saving an invalid timezone string with "${invalidTimezone}"`, async ( { admin, page } ) => { | ||
await admin.visitAdminPage( '/options-general.php' ); | ||
|
||
// Set the timezone to a valid value. | ||
await page.locator( '#timezone_string' ).evaluate( timezone => timezone.value = 'Europe/Lisbon' ); | ||
|
||
// Save changes. | ||
await page.locator( '#submit' ).click(); | ||
|
||
// Set the timezone to an invalid value. | ||
await page.locator( '#timezone_string' ).evaluate( ( timezone, invalidTimezone ) => { | ||
timezone.options[0].value = invalidTimezone; | ||
timezone.value = invalidTimezone; | ||
}, invalidTimezone ); | ||
|
||
// Save changes. | ||
await page.locator( '#submit' ).click(); | ||
|
||
await expect( page.locator( '#timezone_string' ) ).toHaveValue( 'Europe/Lisbon' ); | ||
} ); | ||
} | ||
} ); |