Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/wp-tests-phpunit-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const expectedErrors = [
];

const expectedFailures = [
'Tests_Admin_wpSiteHealth::test_object_cache_thresholds with data set #2',
'Tests_Admin_wpSiteHealth::test_object_cache_thresholds with data set #3',
'Tests_Comment::test_wp_new_comment_respects_comment_field_lengths',
'Tests_Comment::test_wp_update_comment',
'Tests_Comment_CheckComment::test_should_return_false_when_comment_previously_approved_is_enabled_and_author_does_not_have_approved_comment',
'Tests_Comment_CheckComment::test_should_return_true_when_comment_previously_approved_is_enabled_and_author_has_approved_comment',
'Tests_Comment_CheckComment::test_should_return_false_when_comment_previously_approved_is_enabled_and_user_does_not_have_a_previously_approved_comment_with_any_email',
'Tests_DB_Charset::test_get_column_charset with data set #0',
'Tests_DB_Charset::test_get_column_charset with data set #1',
'Tests_DB_Charset::test_get_column_charset with data set #2',
Expand Down Expand Up @@ -87,7 +89,6 @@ const expectedFailures = [
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #6',
'Tests_Menu_Walker_Nav_Menu::test_start_el_with_empty_attributes with data set #7',
'Tests_Menu_wpNavMenu::test_wp_nav_menu_should_not_have_has_children_class_with_custom_depth',
'WP_Test_REST_Posts_Controller::test_get_items_orderby_modified_query',
];

console.log( 'Running WordPress PHPUnit tests with expected failures tracking...' );
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"wp-test-ensure-env": [
"if [ ! -f wordpress/src/wp-load.php ]; then composer run wp-setup; fi",
"@putenv COMPOSE_IGNORE_ORPHANS=true",
"cd wordpress && if [ -z \"$(node tools/local-env/scripts/docker.js ps -q)\" ]; then cd ..; composer run wp-test-start; fi"
"cd wordpress && if [ -z \"$(DOTENV_CONFIG_QUIET=true node tools/local-env/scripts/docker.js ps -q)\" ]; then cd ..; composer run wp-test-start; fi"
],
"wp-test-php": [
"@wp-test-ensure-env @no_additional_args",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4073,10 +4073,10 @@ private function translate_string_literal( WP_Parser_Node $node ): string {
/*
* Translate datetime literals.
*
* Process only strings that could possibly represent a datetime
* literal ("YYYY-MM-DDTHH:MM:SS", "YYYY-MM-DDTHH:MM:SSZ", etc.).
* Process only strings that could possibly represent a date or datetime
* literal ("YYYY-M-D", "YYYY-MM-DDTHH:MM:SSZ", etc.).
*/
if ( strlen( $value ) >= 19 && is_numeric( $value[0] ) ) {
if ( strlen( $value ) >= 8 && is_numeric( $value[0] ) ) {
$value = $this->translate_datetime_literal( $value );
}

Expand Down Expand Up @@ -4681,7 +4681,11 @@ private function translate_function_call( WP_Parser_Node $node ): string {
*/
private function translate_datetime_literal( string $value ): string {
/*
* The code below converts the date format to one preferred by SQLite.
* Normalize MySQL date and datetime literals for SQLite.
*
* MySQL accepts date and time components without zero padding. SQLite
* stores temporal values as text, so they must be normalized for lexical
* comparisons and SQLite date functions to work correctly.
*
* MySQL accepts ISO 8601 date strings: 'YYYY-MM-DDTHH:MM:SSZ'
* SQLite prefers a slightly different format: 'YYYY-MM-DD HH:MM:SS'
Expand All @@ -4704,8 +4708,25 @@ private function translate_datetime_literal( string $value ): string {
* which is true in the unit test suite, but there could also be a timezone offset
* like "+00:00" or "+01:00". We could add support for that later if needed.
*/
if ( 1 === preg_match( '/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})Z$/', $value, $matches ) ) {
$value = $matches[1] . ' ' . $matches[2];
if (
1 === preg_match(
'/^(\d{4})-(\d{1,2})-(\d{1,2})(?:([ T])(\d{1,2}):(\d{1,2}):(\d{1,2})(Z)?)?$/',
$value,
$matches
)
) {
$value = sprintf( '%04d-%02d-%02d', $matches[1], $matches[2], $matches[3] );
if ( isset( $matches[4] ) && '' !== $matches[4] ) {
$is_iso_8601 = 'T' === $matches[4] && 'Z' === ( $matches[8] ?? '' );
$value .= sprintf(
'%s%02d:%02d:%02d%s',
$is_iso_8601 ? ' ' : $matches[4],
$matches[5],
$matches[6],
$matches[7],
$is_iso_8601 ? '' : ( $matches[8] ?? '' )
);
}
}

/*
Expand Down
14 changes: 14 additions & 0 deletions packages/mysql-on-sqlite/tests/WP_SQLite_Driver_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2963,6 +2963,20 @@ public function testSelectFilterByDatesGtLt() {
$this->assertEquals( 'second', $results[0]->option_name );
}

public function testSelectFilterByNonPaddedDates() {
$this->assertQuery( "INSERT INTO _dates (option_name, option_value) VALUES ('first', '2025-02-01 12:00:00');" );
$this->assertQuery( "INSERT INTO _dates (option_name, option_value) VALUES ('second', '2025-03-01 12:00:00');" );

$this->assertQuery(
"SELECT * FROM _dates
WHERE option_value >= '2025-2-01 0:0:0'
AND option_value <= '2025-2-28 23:59:59'"
);
$results = $this->engine->get_query_results();
$this->assertCount( 1, $results );
$this->assertEquals( 'first', $results[0]->option_name );
}

public function testSelectFilterByDatesZeroHour() {
$this->assertQuery( "INSERT INTO _dates (option_name, option_value) VALUES ('first', '2014-10-21 00:42:29');" );
$this->assertQuery( "INSERT INTO _dates (option_name, option_value) VALUES ('second', '2014-10-21 01:42:29');" );
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-sqlite-database-integration/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Contributors: wordpressdotorg, aristath, janjakes, zieladam, berislav.grgicak, bpayton, zaerl
Requires at least: 6.4
Tested up to: 6.9
Tested up to: 7.0
Requires PHP: 7.2
Stable tag: 3.0.0-rc.7
License: GPLv2 or later
Expand Down
2 changes: 1 addition & 1 deletion wp-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

set -e

WP_VERSION="6.7.2"
WP_VERSION="7.0.1"

DIR="$(dirname "$0")"
WP_DIR="$DIR/wordpress"
Expand Down
Loading