Skip to content

Commit 0561e77

Browse files
Docs: Correct swapped variable names and comments in get_weekstartend().
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. This commit corrects the `substr()` positions and `mktime()` argument order so that variable names, comments, and logic are all consistent. Follow-up to [8598], [28918]. Props saratheonline, westonruter. Fixes #65046. git-svn-id: https://develop.svn.wordpress.org/trunk@62421 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 01debdf commit 0561e77

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/wp-includes/functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,16 +586,16 @@ function human_readable_duration( $duration = '' ) {
586586
*/
587587
function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
588588
// MySQL string year.
589-
$my = substr( $mysqlstring, 0, 4 );
589+
$mysql_year = substr( $mysqlstring, 0, 4 );
590590

591591
// MySQL string month.
592-
$mm = substr( $mysqlstring, 8, 2 );
592+
$mysql_month = substr( $mysqlstring, 5, 2 );
593593

594594
// MySQL string day.
595-
$md = substr( $mysqlstring, 5, 2 );
595+
$mysql_day = substr( $mysqlstring, 8, 2 );
596596

597597
// The timestamp for MySQL string day.
598-
$day = mktime( 0, 0, 0, $md, $mm, $my );
598+
$day = mktime( 0, 0, 0, $mysql_month, $mysql_day, $mysql_year );
599599

600600
// The day of the week from the timestamp.
601601
$weekday = (int) gmdate( 'w', $day );

0 commit comments

Comments
 (0)