<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[6276] sites/trunk/api.wordpress.org/public_html/events/1.0: Events: Apply coding standards.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/6276">6276</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/6276","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>iandunn</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-12-14 23:45:18 +0000 (Thu, 14 Dec 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Events: Apply coding standards.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkapiwordpressorgpublic_htmlevents10indexphp">sites/trunk/api.wordpress.org/public_html/events/1.0/index.php</a></li>
<li><a href="#sitestrunkapiwordpressorgpublic_htmlevents10teststestindexphp">sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkapiwordpressorgpublic_htmlevents10indexphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/events/1.0/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/events/1.0/index.php    2017-12-14 23:45:15 UTC (rev 6275)
+++ sites/trunk/api.wordpress.org/public_html/events/1.0/index.php      2017-12-14 23:45:18 UTC (rev 6276)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,10 +31,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * In all of the above scenarios, requests that have cached results will always be served.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        define( 'THROTTLE_STICKY_WORDCAMPS', false );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        define( 'THROTTLE_GEONAMES',    0 );
-       define( 'THROTTLE_IP2LOCATION', 0 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ define( 'THROTTLE_GEONAMES',         0 );
+       define( 'THROTTLE_IP2LOCATION',      0 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        defined( 'DAY_IN_SECONDS' ) or define( 'DAY_IN_SECONDS', 60 * 60 * 24 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ defined( 'DAY_IN_SECONDS'  ) or define( 'DAY_IN_SECONDS', 60 * 60 * 24 );
</ins><span class="cx" style="display: block; padding: 0 10px">         defined( 'WEEK_IN_SECONDS' ) or define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // The test suite just needs the functions defined and doesn't want any headers or output
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,7 +58,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Include dependencies
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function bootstrap() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $base_dir = dirname( dirname(__DIR__ ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $base_dir = dirname( dirname( __DIR__ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        require( $base_dir . '/init.php' );
</span><span class="cx" style="display: block; padding: 0 10px">        require( $base_dir . '/includes/hyperdb/bb-10-hyper-db.php' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -79,7 +79,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // If a precise location is known, use a GET request. The values here should come from the `location` key of the result of a POST request.
</span><span class="cx" style="display: block; padding: 0 10px">        if ( isset( $_GET['latitude'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $location_args['latitude'] = $_GET['latitude'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $location_args['latitude']  = $_GET['latitude'];
</ins><span class="cx" style="display: block; padding: 0 10px">                 $location_args['longitude'] = $_GET['longitude'];
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,9 +112,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * actual public address.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                $public_ip = filter_var(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                    $_REQUEST['ip'],
-                   FILTER_VALIDATE_IP,
-                   FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $_REQUEST['ip'],
+                       FILTER_VALIDATE_IP,
+                       FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $location_args['ip'] = $public_ip ? $public_ip : $_SERVER['REMOTE_ADDR'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -152,7 +152,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! empty( $location['latitude'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $event_args['nearby'] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'latitude' => $location['latitude'],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'latitude'  => $location['latitude'],
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'longitude' => $location['longitude'],
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -361,6 +361,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( false === $long_ip || ! isset( $from, $where ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                wp_cache_set( $cache_key, '__NOT_FOUND__', $cache_group, $cache_life );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">                 return false;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -376,6 +377,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        // Unknown location:
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! $row || '-' == $row->country_short ) {
</span><span class="cx" style="display: block; padding: 0 10px">                wp_cache_set( $cache_key, '__NOT_FOUND__', $cache_group, $cache_life );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">                 return false;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -475,14 +477,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $country_code = get_country_code_from_locale( $args['locale'] ?? '' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $guess = guess_location_from_city( $args['location_name'], $args['timezone'] ?? '', $country_code  );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $guess        = guess_location_from_city( $args['location_name'], $args['timezone'] ?? '', $country_code );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $guess ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $location = array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'description' => $guess->name,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'latitude' => $guess->latitude,
-                               'longitude' => $guess->longitude,
-                               'country' => $guess->country,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'latitude'    => $guess->latitude,
+                               'longitude'   => $guess->longitude,
+                               'country'     => $guess->country,
</ins><span class="cx" style="display: block; padding: 0 10px">                         );
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        $guess = guess_location_from_country( $args['location_name'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -595,8 +597,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! $country && $location_word_count >= 2 ) {
</span><span class="cx" style="display: block; padding: 0 10px">                // Catch input like "Vancouver Canada"
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $country_id   = $location_name_parts[ $location_word_count - 1 ];
-               $country      = get_country_from_name( $country_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $country_id = $location_name_parts[ $location_word_count - 1 ];
+               $country    = get_country_from_name( $country_id );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! $country && $location_word_count >= 3 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -683,34 +685,35 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $wheres = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( !empty( $args['type'] ) && in_array( $args['type'], array( 'meetup', 'wordcamp' ) ) ) {
-               $wheres[] = '`type` = %s';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $args['type'] ) && in_array( $args['type'], array( 'meetup', 'wordcamp' ) ) ) {
+               $wheres[]     = '`type` = %s';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $sql_values[] = $args['type'];
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // If we want nearby events, create a WHERE based on a bounded box of lat/long co-ordinates.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( !empty( $args['nearby'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $args['nearby'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $nearby_where = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                foreach ( $event_distances as $type => $distance ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( !empty( $args['type'] ) && $type != $args['type'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( ! empty( $args['type'] ) && $type != $args['type'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 continue;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $bounded_box = get_bounded_coordinates( $args['nearby']['latitude'], $args['nearby']['longitude'], $distance );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       $bounded_box    = get_bounded_coordinates( $args['nearby']['latitude'], $args['nearby']['longitude'], $distance );
</ins><span class="cx" style="display: block; padding: 0 10px">                         $nearby_where[] = '( `type` = %s AND `latitude` BETWEEN %f AND %f AND `longitude` BETWEEN %f AND %f )';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $sql_values[] = $type;
-                       $sql_values[] = $bounded_box['latitude']['min'];
-                       $sql_values[] = $bounded_box['latitude']['max'];
-                       $sql_values[] = $bounded_box['longitude']['min'];
-                       $sql_values[] = $bounded_box['longitude']['max'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $sql_values[]   = $type;
+                       $sql_values[]   = $bounded_box['latitude']['min'];
+                       $sql_values[]   = $bounded_box['latitude']['max'];
+                       $sql_values[]   = $bounded_box['longitude']['min'];
+                       $sql_values[]   = $bounded_box['longitude']['max'];
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">                // Build the nearby where as a OR as different event types have different distances.
</span><span class="cx" style="display: block; padding: 0 10px">                $wheres[] = '(' . implode( ' OR ', $nearby_where ) . ')';
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Allow queries for limiting to specific countries.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( !empty( $args['country'] ) && preg_match( '![a-z]{2}!i', $args['country'] ) ) {
-               $wheres[] = '`country` = %s';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $args['country'] ) && preg_match( '![a-z]{2}!i', $args['country'] ) ) {
+               $wheres[]     = '`country` = %s';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $sql_values[] = $args['country'];
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -723,7 +726,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Limit 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( isset( $args['number'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $sql_limits = 'LIMIT %d';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $sql_limits   = 'LIMIT %d';
</ins><span class="cx" style="display: block; padding: 0 10px">                 $sql_values[] = $args['number'];
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -757,16 +760,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $events = array();
</span><span class="cx" style="display: block; padding: 0 10px">        foreach ( $raw_events as $event ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $events[] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'type'  => $event->type,
-                       'title' => $event->title,
-                       'url'   => $event->url,
-                       'meetup' => $event->meetup,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'type'       => $event->type,
+                       'title'      => $event->title,
+                       'url'        => $event->url,
+                       'meetup'     => $event->meetup,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'meetup_url' => $event->meetup_url,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'date' => $event->date_utc, // TODO: DB stores a local date, not UTC.
-                       'location' => array(
-                               'location' => $event->location,
-                               'country' => $event->country,
-                               'latitude' => (float) $event->latitude,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'date'       => $event->date_utc, // TODO: DB stores a local date, not UTC.
+                       'location'   => array(
+                               'location'  => $event->location,
+                               'country'   => $event->country,
+                               'latitude'  => (float) $event->latitude,
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'longitude' => (float) $event->longitude,
</span><span class="cx" style="display: block; padding: 0 10px">                        )
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -774,7 +777,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        wp_cache_set( $cache_key, $events, $cache_group, $cache_life );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        return $events; 
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $events;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -857,11 +860,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! empty( $request_args['nearby'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $bounded_box = get_bounded_coordinates( $request_args['nearby']['latitude'], $request_args['nearby']['longitude'], $distance );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $where[]  = '( `latitude` BETWEEN %f AND %f AND `longitude` BETWEEN %f AND %f )';
-               $values[] = $bounded_box['latitude']['min'];
-               $values[] = $bounded_box['latitude']['max'];
-               $values[] = $bounded_box['longitude']['min'];
-               $values[] = $bounded_box['longitude']['max'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $where[]     = '( `latitude` BETWEEN %f AND %f AND `longitude` BETWEEN %f AND %f )';
+               $values[]    = $bounded_box['latitude']['min'];
+               $values[]    = $bounded_box['latitude']['max'];
+               $values[]    = $bounded_box['longitude']['min'];
+               $values[]    = $bounded_box['longitude']['max'];
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Allow queries for limiting to specific countries.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -903,7 +906,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return array
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function add_regional_wordcamps( $local_events, $user_agent ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $time = time();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $time               = time();
</ins><span class="cx" style="display: block; padding: 0 10px">         $regional_wordcamps = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! is_client_core( $user_agent ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -967,14 +970,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @param float $lat            The latitude of the location.
</span><span class="cx" style="display: block; padding: 0 10px">  * @param float $lon            The longitude of the location.
</span><span class="cx" style="display: block; padding: 0 10px">  * @param int   $distance_in_km The distance of the bounded box, in KM.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px">  * @return array of bounded box.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_bounded_coordinates( $lat, $lon, $distance_in_km = 50 ) {
</span><span class="cx" style="display: block; padding: 0 10px">        // Based on http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $angular_distance = $distance_in_km / 6371; // 6371 = radius of the earth in KM.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $lat = deg2rad( $lat );
-       $lon = deg2rad( $lon );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $lat              = deg2rad( $lat );
+       $lon              = deg2rad( $lon );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $earth_min_lat = -1.5707963267949; // = deg2rad(  -90 ) = -PI/2
</span><span class="cx" style="display: block; padding: 0 10px">        $earth_max_lat =  1.5707963267949; // = deg2rad(   90 ) =  PI/2
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -985,21 +989,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $maximum_lat = $lat + $angular_distance;
</span><span class="cx" style="display: block; padding: 0 10px">        $minimum_lon = $maximum_lon = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // Ensure that we're not within a pole-area of the world, weirdness will ensure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Ensure that we're not within a pole-area of the world, weirdness will ensue.
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( $minimum_lat > $earth_min_lat && $maximum_lat < $earth_max_lat ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $lon_delta   = asin( sin( $angular_distance ) / cos( $lat ) );
+               $minimum_lon = $lon - $lon_delta;
+               $maximum_lon = $lon + $lon_delta;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $lon_delta = asin( sin( $angular_distance ) / cos( $lat ) );
-
-               $minimum_lon = $lon - $lon_delta;
</del><span class="cx" style="display: block; padding: 0 10px">                 if ( $minimum_lon < $earth_min_lon ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $minimum_lon += 2 * pi();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $maximum_lon = $lon + $lon_delta;
</del><span class="cx" style="display: block; padding: 0 10px">                 if ( $maximum_lon > $earth_max_lon ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $maximum_lon -= 2 * pi();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">         } else {
</span><span class="cx" style="display: block; padding: 0 10px">                // Use a much simpler range in polar regions.
</span><span class="cx" style="display: block; padding: 0 10px">                $minimum_lat = max( $minimum_lat, $earth_min_lat );
</span></span></pre></div>
<a id="sitestrunkapiwordpressorgpublic_htmlevents10teststestindexphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php 2017-12-14 23:45:15 UTC (rev 6275)
+++ sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php   2017-12-14 23:45:18 UTC (rev 6276)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,6 +11,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function run_tests() {
</span><span class="cx" style="display: block; padding: 0 10px">        global $wpdb;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">         define( 'RUNNING_TESTS', true );
</span><span class="cx" style="display: block; padding: 0 10px">        define( 'SAVEQUERIES',   true );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,6 +23,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $tests_failed += test_add_regional_wordcamps();
</span><span class="cx" style="display: block; padding: 0 10px">        $tests_failed += test_build_response();
</span><span class="cx" style="display: block; padding: 0 10px">        $tests_failed += test_is_client_core();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">         $query_count  = count( $wpdb->queries );
</span><span class="cx" style="display: block; padding: 0 10px">        $query_time   = array_sum( array_column( $wpdb->queries, 1 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -97,7 +99,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $actual_result['longitude'] = number_format( round( $actual_result['longitude'], 3 ), 3 );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $passed      = $case['expected'] === $actual_result;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $passed = $case['expected'] === $actual_result;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                output_results( $case_id, $passed, $case['expected'], $actual_result );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -115,7 +117,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return array
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_location_test_cases() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         $cases = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cases = array(
</ins><span class="cx" style="display: block; padding: 0 10px">                 /*
</span><span class="cx" style="display: block; padding: 0 10px">                 * Only the country code is given
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,7 +141,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'timezone'      => 'Asia/Jakarta',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'expected' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'country' => 'ID',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'country'     => 'ID',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'description' => 'indonesia',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -387,7 +389,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * This is currently failing. A query from PHP shows row id 2220957 has "Yaound?" instead of
</span><span class="cx" style="display: block; padding: 0 10px">                 * "Yaoundé", but it's correct in the database itself.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 'city-endonym-accents-africa' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         'city-endonym-accents-africa' => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                         'input' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'location_name' => 'Yaoundé',
</span><span class="cx" style="display: block; padding: 0 10px">                                'locale'        => 'fr_FR',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -640,7 +642,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'timezone'      => 'America/Vancouver',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'expected' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'country' => 'CA',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'country'     => 'CA',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'description' => 'canada',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -652,7 +654,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'timezone'      => 'America/Santo_Domingo',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'expected' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'country' => 'DO',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'country'     => 'DO',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'description' => 'dominican republic',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -664,7 +666,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'timezone'      => 'Africa/Bangui',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'expected' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'country' => 'CF',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'country'     => 'CF',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'description' => 'central african republic',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -676,7 +678,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'timezone'      => 'Europe/London',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'expected' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'country' => 'GB',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'country'     => 'GB',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'description' => 'united kingdom',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -688,7 +690,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'timezone'      => 'Africa/Bujumbura',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'expected' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'country' => 'BI',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'country'     => 'BI',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'description' => 'burundi',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -889,9 +891,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $actual_result = get_events( $case['input'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $passed = $case['expected']['count'] === count( $actual_result ) &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        ! empty( $actual_result[0]['url'] ) &&
-                       strtotime( $actual_result[0]['date'] ) > time() - ( 2 * 24 * 60 * 60 ) &&
-                       $case['expected']['country'] === strtoupper( $actual_result[0]['location']['country'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                   ! empty( $actual_result[0]['url'] ) &&
+                         strtotime( $actual_result[0]['date'] ) > time() - ( 2 * 24 * 60 * 60 ) &&
+                         $case['expected']['country'] === strtoupper( $actual_result[0]['location']['country'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                output_results( $case_id, $passed, $case['expected'], $actual_result );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -927,7 +929,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                '1-in-australia' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'input' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'number' => '1',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'number'  => '1',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'country' => 'AU',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'expected' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -957,13 +959,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        foreach ( $cases as $case_id => $case ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $actual_result = build_response( $case['input']['location'], $case['input']['location_args'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $passed = $case['expected']['location'] === $actual_result['location'] &&
-                       isset( $case['expected']['error'] ) === isset( $actual_result['error'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $passed = $case['expected']['location']       === $actual_result['location'] &&
+                         isset( $case['expected']['error'] ) === isset( $actual_result['error'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $passed && $case['expected']['events'] ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $passed = ! empty( $actual_result['events'] ) &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                ! empty( $actual_result['events'][0]['url'] ) &&
-                               strtotime( $actual_result['events'][0]['date'] ) > time() - ( 2 * 24 * 60 * 60 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                           ! empty( $actual_result['events'][0]['url'] ) &&
+                                 strtotime( $actual_result['events'][0]['date'] ) > time() - ( 2 * 24 * 60 * 60 );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $passed && isset( $case['expected']['error'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1062,9 +1064,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        foreach ( $cases as $user_agent => $expected_result ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $actual_result = is_client_core( $user_agent );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $passed        = $expected_result === $actual_result;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $passed = $expected_result === $actual_result;
-
</del><span class="cx" style="display: block; padding: 0 10px">                 output_results( $user_agent, $passed, $expected_result, $actual_result );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! $passed ) {
</span></span></pre>
</div>
</div>

</body>
</html>