Changeset 10474
- Timestamp:
- 11/30/2020 03:59:30 AM (4 years ago)
- Location:
- sites/trunk/api.wordpress.org/public_html/events/1.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r10470 r10474 348 348 // Exact match 349 349 $query = ' 350 SELECT name, latitude, longitude, country 350 SELECT name, latitude, longitude, country, type 351 351 FROM geoname_summary 352 352 WHERE name = %s … … 354 354 FIELD( %s, country ) DESC, 355 355 FIELD( %s, timezone ) DESC, 356 LEFT( type, 1 ) = "P" DESC, 356 357 population DESC, 357 358 BINARY LOWER( %s ) = BINARY LOWER( name ) DESC … … 369 370 if ( ! $row && $wildcard && 'ASCII' !== mb_detect_encoding( $location_name ) ) { 370 371 $query = ' 371 SELECT name, latitude, longitude, country 372 SELECT name, latitude, longitude, country, type 372 373 FROM geoname_summary 373 374 WHERE name LIKE %s … … 375 376 FIELD( %s, country ) DESC, 376 377 FIELD( %s, timezone ) DESC, 378 LEFT( type, 1 ) = "P" DESC, 377 379 population DESC, 378 380 BINARY LOWER( %s ) = BINARY LOWER( LEFT( name, %d ) ) DESC … … 547 549 $guess = guess_location_from_city( $args['location_name'], $args['timezone'] ?? '', $country_code ); 548 550 549 if ( $guess ) { 551 $country_types = array( 552 // See http://download.geonames.org/export/dump/featureCodes_en.txt 553 554 'A.PCL', // political entity 555 'A.PCLD', // dependent political entity 556 'A.PCLF', // freely associated state 557 'A.PCLH', // historical political entity a former political entity 558 'A.PCLI', // independent political entity 559 'A.PCLIX', // section of independent political entity 560 'A.PCLS', // semi-independent political entity 561 'A.PRSH', // parish an ecclesiastical district 562 'A.TERR', // territory 563 'A.ZN', // zone 564 ); 565 566 if ( $guess && in_array( $guess->type, $country_types, true ) ) { 567 $location = array( 568 'country' => $guess->country, 569 'description' => $guess->name, 570 ); 571 } elseif ( $guess ) { 550 572 $location = array( 551 573 'description' => $guess->name, -
sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php
r10271 r10474 189 189 'city-invalid-private-ip' => array( 190 190 'input' => array( 191 'location_name' => ' Rivendell',191 'location_name' => 'InvalidCity', 192 192 'ip' => '127.0.0.1', 193 193 ), … … 409 409 /* 410 410 * The city endonym, locale, and timezone are given 411 *412 * @todo413 * This is currently failing. A query from PHP shows row id 2220957 has "Yaound?" instead of414 * "Yaoundé", but it's correct in the database itself.415 411 */ 416 412 'city-endonym-accents-africa' => array( … … 421 417 ), 422 418 'expected' => array( 423 'description' => 'yaound e',419 'description' => 'yaoundé', 424 420 'latitude' => '3.867', 425 421 'longitude' => '11.517', … … 563 559 'expected' => array( 564 560 'description' => 'Санкт-Петербург', 565 'latitude' => '59. 894',566 'longitude' => '30. 264',561 'latitude' => '59.939', 562 'longitude' => '30.314', 567 563 'country' => 'RU', 568 564 ), … … 578 574 'expected' => array( 579 575 'description' => 'Санкт-Петербург', 580 'latitude' => '59. 894',581 'longitude' => '30. 264',576 'latitude' => '59.939', 577 'longitude' => '30.314', 582 578 'country' => 'RU', 583 579 ), … … 639 635 'expected' => array( 640 636 'description' => 'portland', 641 'latitude' => '43.6 61',642 'longitude' => '-70.25 5',637 'latitude' => '43.657', 638 'longitude' => '-70.259', 643 639 'country' => 'US', 644 640 ), … … 652 648 ), 653 649 'expected' => array( 654 'description' => 's ao',650 'description' => 'são paulo', 655 651 'latitude' => '-23.548', 656 652 'longitude' => '-46.636',
Note: See TracChangeset
for help on using the changeset viewer.