From 0c1d48a86b55a88bfaed4345a406ee3cbf509b1d Mon Sep 17 00:00:00 2001 From: saratheonline Date: Thu, 9 Apr 2026 12:33:52 +0530 Subject: [PATCH] Date/Time: Fix swapped variable names and comments in get_weekstartend(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variables `$mm` and `$md` had their substr() positions and inline comments swapped — `$mm` was extracting the day digits (position 8) while `$md` was extracting the month digits (position 5), contrary to what the comments indicated. The output was accidentally correct because the two mistakes cancelled each other out in the mktime() call, but the misleading naming posed a future maintenance risk. Corrects the substr() positions and mktime() argument order so that variable names, comments, and logic are all consistent. --- src/wp-includes/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 85b6043b0b5c8..96ca656920af4 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -589,13 +589,13 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) { $my = substr( $mysqlstring, 0, 4 ); // MySQL string month. - $mm = substr( $mysqlstring, 8, 2 ); + $mm = substr( $mysqlstring, 5, 2 ); // MySQL string day. - $md = substr( $mysqlstring, 5, 2 ); + $md = substr( $mysqlstring, 8, 2 ); // The timestamp for MySQL string day. - $day = mktime( 0, 0, 0, $md, $mm, $my ); + $day = mktime( 0, 0, 0, $mm, $md, $my ); // The day of the week from the timestamp. $weekday = (int) gmdate( 'w', $day );