Skip to content

Commit e4f3252

Browse files
westonruterclaude
andcommitted
Date/Time: Clamp the start of the week in get_calendar().
The `start_of_week` option is cast to an int but otherwise unchecked, so a negative value makes `( $wdcount + $week_begins ) % 7` negative, and a value above 6 is out of range for `WP_Locale::get_weekday()`. Either leads to an undefined array key. Clamping it to 0-6 keeps the weekday headers valid and satisfies the new `int<0, 6>` type of `WP_Locale::get_weekday()`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fefbbea commit e4f3252

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/wp-includes/general-template.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@ function get_calendar( $args = array() ) {
26662666
}
26672667

26682668
// week_begins = 0 stands for Sunday.
2669-
$week_begins = (int) get_option( 'start_of_week' );
2669+
$week_begins = clamp( (int) get_option( 'start_of_week' ), 0, 6 );
26702670

26712671
// Read the current date.
26722672
list( $current_year, $current_month, $current_day ) = array_map( 'intval', explode( '-', current_time( 'Y-m-j' ) ) );

0 commit comments

Comments
 (0)