Making WordPress.org


Ignore:
Timestamp:
11/26/2020 04:26:18 AM (3 years ago)
Author:
dd32
Message:

Events API: remove the UTF8 database connection juggling, which shouldn't be needed anymore.

See #3728.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/events/1.0/index.php

    r10341 r10469  
    11<?php
    2 
    32namespace Dotorg\API\Events;
    43use stdClass;
     
    358357        LIMIT 1';
    359358
    360     $prepared_query = $wpdb->prepare( $query, $location_name, $country, $timezone, $location_name );
    361     $db_handle      = $wpdb->db_connect( $prepared_query );
    362 
    363     $wpdb->set_charset( $db_handle, 'utf8' ); // The content in this table requires a UTF8 connection.
    364     $row = $wpdb->get_row( $prepared_query );
    365     $wpdb->set_charset( $db_handle, 'latin1' ); // Revert to the default charset to avoid affecting other queries.
     359    $row = $wpdb->get_row( $wpdb->prepare(
     360        $query,
     361        $location_name,
     362        $country,
     363        $timezone,
     364        $location_name
     365    ) );
    366366
    367367    // Wildcard match
     
    378378            LIMIT 1';
    379379
    380         $prepared_query = $wpdb->prepare( $query, $wpdb->esc_like( $location_name ) . '%', $country, $timezone, $location_name, mb_strlen( $location_name ) );
    381         $db_handle      = $wpdb->db_connect( $prepared_query );
    382 
    383         $wpdb->set_charset( $db_handle, 'utf8' ); // The content in this table requires a UTF8 connection.
    384         $row = $wpdb->get_row( $prepared_query );
    385         $wpdb->set_charset( $db_handle, 'latin1' ); // Revert to the default charset to avoid affecting other queries.
    386     }
    387 
    388     // Suffix the "State", good in some countries (western countries) horrible in others
    389     // (where geonames data is not as complete, or region names are similar (but not quite the same) to city names)
    390     // LEFT JOIN admin1codes ac ON gs.statecode = ac.code
    391     // if ( $row->state && $row->state != $row->name && $row->name NOT CONTAINED WITHIN $row->state? ) {
    392     //   $row->name .= ', ' . $row->state;
    393     // }
     380        $row = $wpdb->get_row( $wpdb->prepare(
     381            $query,
     382            $wpdb->esc_like( $location_name ) . '%',
     383            $country,
     384            $timezone,
     385            $location_name,
     386            mb_strlen( $location_name )
     387        ) );
     388    }
    394389
    395390    // Strip off null bytes
Note: See TracChangeset for help on using the changeset viewer.