Make WordPress Core


Ignore:
Timestamp:
11/28/2024 10:50:21 PM (2 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r59461 r59471  
    595595
    596596    // The day of the week from the timestamp.
    597     $weekday = gmdate( 'w', $day );
     597    $weekday = (int) gmdate( 'w', $day );
    598598
    599599    if ( ! is_numeric( $start_of_week ) ) {
    600         $start_of_week = get_option( 'start_of_week' );
     600        $start_of_week = (int) get_option( 'start_of_week' );
    601601    }
    602602
     
    610610    // $start + 1 week - 1 second.
    611611    $end = $start + WEEK_IN_SECONDS - 1;
     612
    612613    return compact( 'start', 'end' );
    613614}
Note: See TracChangeset for help on using the changeset viewer.