Make WordPress Core

Ticket #52220: 52220_1.diff

File 52220_1.diff, 3.0 KB (added by sawf1y, 3 months ago)

final solution

  • src/wp-includes/functions.php

    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index f5002a45de..97de19ee8b 100644
    a b function _wp_mysql_week( $column ) {  
    71827182        $start_of_week = (int) get_option( 'start_of_week' );
    71837183        switch ( $start_of_week ) {
    71847184                case 1:
    7185                         return "WEEK( $column, 1 )";
     7185                        return "WEEK( $column, 3 )";
    71867186                case 2:
    71877187                case 3:
    71887188                case 4:
    71897189                case 5:
    71907190                case 6:
    7191                         return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )";
     7191                        return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 2 )";
    71927192                case 0:
    71937193                default:
    7194                         return "WEEK( $column, 0 )";
     7194                        return "WEEK( $column, 2 )";
    71957195        }
    71967196}
    71977197
  • tests/phpunit/tests/functions/wpMysqlWeek.php

    diff --git a/tests/phpunit/tests/functions/wpMysqlWeek.php b/tests/phpunit/tests/functions/wpMysqlWeek.php
    index 3649ee6c4c..340f614889 100644
    a b class Tests_Functions_WpMysqlWeek extends WP_UnitTestCase {  
    3131         */
    3232        public function data_wp_mysql_week() {
    3333                return array(
    34                         array( '1969-12-25', 0, 'WEEK( col_name, 0 )' ),
    35                         array( '1969-12-25', 1, 'WEEK( col_name, 1 )' ),
    36                         array( '1969-12-25', 2, 'WEEK( DATE_SUB( col_name, INTERVAL 2 DAY ), 0 )' ),
    37                         array( '1969-12-25', 3, 'WEEK( DATE_SUB( col_name, INTERVAL 3 DAY ), 0 )' ),
    38                         array( '1969-12-25', 4, 'WEEK( DATE_SUB( col_name, INTERVAL 4 DAY ), 0 )' ),
    39                         array( '1969-12-25', 5, 'WEEK( DATE_SUB( col_name, INTERVAL 5 DAY ), 0 )' ),
    40                         array( '1969-12-25', 6, 'WEEK( DATE_SUB( col_name, INTERVAL 6 DAY ), 0 )' ),
    41                         array( '1969-12-25', 9, 'WEEK( col_name, 0 )' ),
     34                        array( '1969-12-25', 0, 'WEEK( col_name, 2 )' ),
     35                        array( '1969-12-25', 1, 'WEEK( col_name, 3 )' ),
     36                        array( '1969-12-25', 2, 'WEEK( DATE_SUB( col_name, INTERVAL 2 DAY ), 2 )' ),
     37                        array( '1969-12-25', 3, 'WEEK( DATE_SUB( col_name, INTERVAL 3 DAY ), 2 )' ),
     38                        array( '1969-12-25', 4, 'WEEK( DATE_SUB( col_name, INTERVAL 4 DAY ), 2 )' ),
     39                        array( '1969-12-25', 5, 'WEEK( DATE_SUB( col_name, INTERVAL 5 DAY ), 2 )' ),
     40                        array( '1969-12-25', 6, 'WEEK( DATE_SUB( col_name, INTERVAL 6 DAY ), 2 )' ),
     41                        array( '1969-12-25', 9, 'WEEK( col_name, 2 )' ),
    4242                );
    4343        }
    4444}
  • tests/phpunit/tests/query/dateQuery.php

    diff --git a/tests/phpunit/tests/query/dateQuery.php b/tests/phpunit/tests/query/dateQuery.php
    index a43e19f2b6..ab8763b495 100644
    a b class Tests_Query_DateQuery extends WP_UnitTestCase {  
    953953
    954954                $this->assertSame( array( $p2 ), wp_list_pluck( $posts, 'ID' ) );
    955955
    956                 $this->assertStringContainsString( "WEEK( $wpdb->posts.post_date, 1 ) = 43", $this->q->request );
    957                 $this->assertStringNotContainsString( "WEEK( $wpdb->posts.post_date, 1 ) = 42", $this->q->request );
     956                $this->assertStringContainsString( "WEEK( $wpdb->posts.post_date, 3 ) = 43", $this->q->request );
     957                $this->assertStringNotContainsString( "WEEK( $wpdb->posts.post_date, 3 ) = 42", $this->q->request );
    958958        }
    959959
    960960        /**