Making WordPress.org

Ticket #4480: 4480.2.diff

File 4480.2.diff, 5.4 KB (added by iandunn, 5 years ago)

complete version of 4480.diff

  • 1.0/index.php

    diff --git 1.0/index.php 1.0/index.php
    index ee81304..132ae97 100644
    function main() { 
    3434        define( 'THROTTLE_GEONAMES',         0 );
    3535        define( 'THROTTLE_IP2LOCATION',      0 );
    3636
    37         defined( 'DAY_IN_SECONDS'  ) or define( 'DAY_IN_SECONDS', 60 * 60 * 24 );
     37        defined( 'HOUR_IN_SECONDS' ) or define( 'HOUR_IN_SECONDS', 60 * 60 );
     38        defined( 'DAY_IN_SECONDS'  ) or define( 'DAY_IN_SECONDS', HOUR_IN_SECONDS * 24 );
    3839        defined( 'WEEK_IN_SECONDS' ) or define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
    3940
    4041        // The test suite just needs the functions defined and doesn't want any headers or output
    function get_events( $args = array() ) { 
    868869                        'url'        => $event->url,
    869870                        'meetup'     => $event->meetup,
    870871                        'meetup_url' => $event->meetup_url,
    871                         'date'       => $event->date_utc, // TODO: DB stores a local date, not UTC.
     872
     873                        /*
     874                         * The `date_utc` column in the database is misnomed, and contains times in the event's local
     875                         * timezone. So the `date` field in the response is the local time, and the `date_utc` field in
     876                         * the response here is _actually_ UTC.
     877                         */
     878                        'date'       => $event->date_utc,
    872879                        'end_date'   => $event->end_date,
     880                        'start_unix_timestamp'  => strtotime( $event->date_utc ) - $event->date_utc_offset,
     881                        'end_unix_timestamp'    => strtotime( $event->end_date ) - $event->date_utc_offset,
     882
    873883
    874884                        'location'   => array(
    875885                                // Capitalize it for use in presentation contexts, like the Events Widget.
    function get_regional_wordcamp_data() { 
    10311041                                'meetup_url' => '',
    10321042                                'date'       => '2020-02-21 00:00:00',
    10331043                                'end_date'   => '2020-02-23 00:00:00',
     1044                                'start_unix_timestamp' => strtotime( '2020-02-21 00:00:00' ) - 7 * HOUR_IN_SECONDS,
     1045                                'end_unix_timestamp'   => strtotime( '2020-02-23 00:00:00' ) - 7 * HOUR_IN_SECONDS,
    10341046
    10351047                                'location' => array(
    10361048                                        'location'  => 'Bangkok, Thailand',
    function get_regional_wordcamp_data() { 
    10561068                                'meetup_url' => '',
    10571069                                'date'       => '2020-06-04 00:00:00',
    10581070                                'end_date'   => '2020-06-06 00:00:00',
     1071                                'start_unix_timestamp' => strtotime( '2020-06-04 00:00:00' ) - 1 * HOUR_IN_SECONDS,
     1072                                'end_unix_timestamp'   => strtotime( '2020-06-06 00:00:00' ) - 1 * HOUR_IN_SECONDS,
    10591073
    10601074                                'location' => array(
    10611075                                        'location'  => 'Online',
    function get_regional_wordcamp_data() { 
    10821096                                'meetup_url' => '',
    10831097                                'date'       => '2020-10-27 00:00:00',
    10841098                                'end_date'   => '2020-10-29 00:00:00',
     1099                                'start_unix_timestamp' => strtotime( '2020-10-27 00:00:00' ) - 5 * HOUR_IN_SECONDS,
     1100                                'end_unix_timestamp'   => strtotime( '2020-10-29 00:00:00' ) - 5 * HOUR_IN_SECONDS,
    10851101
    10861102                                'location' => array(
    10871103                                        'location'  => 'Online',
    function maybe_add_wp15_promo( $local_events, $user_agent, $time ) { 
    12701286                        'meetup'     => '',
    12711287                        'meetup_url' => '',
    12721288                        'date'       => '2018-05-27 12:00:00',
     1289                        'end_date'   => '2018-05-27 12:00:00',
     1290                        'start_unix_timestamp' => strtotime( '2018-05-27 12:00:00' ),
     1291                        'end_unix_timestamp'   => strtotime( '2018-05-27 12:00:00' ),
     1292
    12731293                        'location'   => array(
    12741294                                'location' => 'Everywhere',
    12751295                        ),
    function pin_next_online_wordcamp( $events, $user_agent, $current_time ) { 
    13401360        if ( false === $next_online_camp ) {
    13411361                $raw_camp = $wpdb->get_row( "
    13421362                        SELECT
    1343                                 `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `end_date`, `country`, `latitude`, `longitude`
     1363                                `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `date_utc_offset`, `end_date`, `country`, `latitude`, `longitude`
    13441364                        FROM `wporg_events`
    13451365                        WHERE
    13461366                                type     = 'wordcamp'  AND
    function pin_next_online_wordcamp( $events, $user_agent, $current_time ) { 
    13581378                                'url'        => $raw_camp->url,
    13591379                                'meetup'     => $raw_camp->meetup,
    13601380                                'meetup_url' => $raw_camp->meetup_url,
     1381
     1382                                // See notes about UTC in `get_events()`.
    13611383                                'date'       => $raw_camp->date_utc,
    13621384                                'end_date'   => $raw_camp->end_date,
     1385                                'start_unix_timestamp'  => strtotime( $raw_camp->date_utc ) - $raw_camp->date_utc_offset,
     1386                                'end_unix_timestamp'    => strtotime( $raw_camp->end_date ) - $raw_camp->date_utc_offset,
     1387
     1388                                // cod standards commit after this commit
    13631389
    13641390                                'location'   => array(
    13651391                                        'location'  => 'Online',
    function pin_next_workshop_discussion_group( $events, $user_agent ) { 
    14151441
    14161442        if ( ! $found ) {
    14171443                $raw_discussion_group = $wpdb->get_row( "
    1418                         SELECT `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `end_date`, `country`, `latitude`, `longitude`
     1444                        SELECT `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `date_utc_offset`, `end_date`, `country`, `latitude`, `longitude`
    14191445                        FROM `wporg_events`
    14201446                        WHERE
    14211447                                type       = 'meetup'    AND
    function pin_next_workshop_discussion_group( $events, $user_agent ) { 
    14341460                                'url'        => $raw_discussion_group->url,
    14351461                                'meetup'     => $raw_discussion_group->meetup,
    14361462                                'meetup_url' => $raw_discussion_group->meetup_url,
     1463
     1464                                // See notes about UTC in `get_events()`.
    14371465                                'date'       => $raw_discussion_group->date_utc,
    14381466                                'end_date'   => $raw_discussion_group->end_date,
     1467                                'start_unix_timestamp' => strtotime( $raw_discussion_group->date_utc ) - $raw_discussion_group->date_utc_offset,
     1468                                'end_unix_timestamp'   => strtotime( $raw_discussion_group->end_date ) - $raw_discussion_group->date_utc_offset,
    14391469
    14401470                                'location'   => array(
    14411471                                        'location'  => 'Online',