From dd967e2a2ea96e3a93b05a887477a0d487aa7d79 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 28 Nov 2024 22:52:17 +0000 Subject: [PATCH] Coding Standards: Cast `gmdate( 'w' )` to `int` before using as integer. This addresses several instances of `gmdate( 'w' )` being used directly as an integer, when it's actually a numeric string. The issue is remediated by casting the value to `int` before use. Affected functions: * `get_calendar()` * `get_weekstartend()` Follow-up to [508], [1632]. Props justlevine. See #52217. Built from https://develop.svn.wordpress.org/trunk@59471 git-svn-id: http://core.svn.wordpress.org/trunk@58857 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 5 +++-- wp-includes/general-template.php | 6 +++--- wp-includes/version.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index a4cfa13cd2..dd0066cf3f 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -594,10 +594,10 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) { $day = mktime( 0, 0, 0, $md, $mm, $my ); // The day of the week from the timestamp. - $weekday = gmdate( 'w', $day ); + $weekday = (int) gmdate( 'w', $day ); if ( ! is_numeric( $start_of_week ) ) { - $start_of_week = get_option( 'start_of_week' ); + $start_of_week = (int) get_option( 'start_of_week' ); } if ( $weekday < $start_of_week ) { @@ -609,6 +609,7 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) { // $start + 1 week - 1 second. $end = $start + WEEK_IN_SECONDS - 1; + return compact( 'start', 'end' ); } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 1d9fc98b84..e96f0f7c37 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -2373,7 +2373,7 @@ function get_calendar( $initial = true, $display = true ) { } // See how much we should pad in the beginning. - $pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins ); + $pad = calendar_week_mod( (int) gmdate( 'w', $unixmonth ) - $week_begins ); if ( 0 != $pad ) { $calendar_output .= "\n\t\t" . ' '; } @@ -2412,12 +2412,12 @@ function get_calendar( $initial = true, $display = true ) { $calendar_output .= ''; - if ( 6 == calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) { + if ( 6 == calendar_week_mod( (int) gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) { $newrow = true; } } - $pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ); + $pad = 7 - calendar_week_mod( (int) gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ); if ( 0 != $pad && 7 != $pad ) { $calendar_output .= "\n\t\t" . ' '; } diff --git a/wp-includes/version.php b/wp-includes/version.php index b8a13ad006..2112c06b61 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59470'; +$wp_version = '6.8-alpha-59471'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.