Commit 7e83f696 authored by lyricnz's avatar lyricnz
Browse files

Issue #1161512: replace split() with explode(), and clean up a couple of warnings

parent bdc8d727
......@@ -64,7 +64,7 @@ function geonames_metadata_update() {
// Insert all records from the HTTP response
$num = preg_match_all('/^[A-Z].*?$/ms', $file->data, $matches);
foreach ($matches[0] as $line) {
$object = array_combine($field_names, split("\t", $line));
$object = array_combine($field_names, explode("\t", $line));
if ($object['geonameid'] != 0) {
drupal_write_record($tablename, $object);
}
......@@ -89,11 +89,11 @@ function geonames_metadata_update() {
$field_names = array_keys($schema['fields']);
// Insert all records from the HTTP response
$lines = split("\n", $file->data);
$lines = explode("\n", $file->data);
foreach ($lines as $line) {
if (trim($line) != '' && substr($line, 0, 1) != '#' && substr($line, 0, 4) != 'null') {
$a = split("\t", $line);
$b = split("\.", $a[0]);
$a = explode("\t", $line);
$b = explode(".", $a[0]);
$object = array_combine($field_names, array($b[0], $b[1], $a[1], $a[2]));
drupal_write_record($tablename, $object);
}
......@@ -625,6 +625,8 @@ function geonames_query_required_parameters_set($service, $query, $single = 'sin
* $result object
*/
function geonames_parse_xml($data, $columns = FALSE) {
$result = new stdClass();
// temporary solution; get stuff from XML tag to distinguish between pay-service and free service
preg_match('/<\?xml version="(.*)" encoding="([a-zA-Z\-0-9]*)"(.*)\?>/', $data, $regs);
if ($regs[3]) {
......@@ -733,6 +735,7 @@ function geonames_parse_get_xml($data) {
* Parser for astergdem/srtm3/gtopo30 services.
*/
function geonames_parse_elevation_xml($data) {
$result = new stdClass();
$types = array('astergdem', 'srtm3', 'gtopo30');
$xml = new SimpleXMLElement($data);
foreach ($types as $key) {
......
......@@ -10,7 +10,7 @@ class GeoNamesAllTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo().
*/
function getInfo() {
public static function getInfo() {
return array(
'name' => t('GeoNames All'),
'description' => t('Exercise every query supported by the GeoNames module - requires internet access.'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment