diff --git a/application/config/version.php b/application/config/version.php index 20396bd466..952de74077 100644 --- a/application/config/version.php +++ b/application/config/version.php @@ -29,14 +29,14 @@ * * @var string */ -$config['version'] = '8.23.0'; +$config['version'] = '8.23.2'; /** * Version release date. * * @var string */ -$config['release_date'] = '2023-09-20'; +$config['release_date'] = '2023-09-21'; /** * Link to the code repository downloads page. diff --git a/application/libraries/MY_ORM.php b/application/libraries/MY_ORM.php index da603a1cda..8505a24fe4 100644 --- a/application/libraries/MY_ORM.php +++ b/application/libraries/MY_ORM.php @@ -158,6 +158,10 @@ public function last_query() { * the insert. Setting this to TRUE causes a more reliable method of * detecting the inserted record ID to be used which avoids this problem. * + * In order for this method to work the sequence must be associated with + * the table. You may need to execute a query like + * ALTER SEQUENCE occurrences_id_seq OWNED BY occurrences.id + * * @var bool */ protected $hasTriggerWithSequence = FALSE; diff --git a/application/models/occurrence.php b/application/models/occurrence.php index f1be62f8f0..4496adf8a3 100644 --- a/application/models/occurrence.php +++ b/application/models/occurrence.php @@ -82,6 +82,16 @@ class Occurrence_Model extends ORM { ], ]; + /** + * Indicates database trigger on table which accesses a sequence. + * + * Set to true as set_occurrence_to_training_from_sample_trigger was + * added. + * + * @var bool + */ + protected $hasTriggerWithSequence = TRUE; + /** * Methods of identifying duplicates during import. * diff --git a/modules/indicia_setup/db/version_8_23_2/202309211405_set_occurrences_id_seq_owned_by.sql b/modules/indicia_setup/db/version_8_23_2/202309211405_set_occurrences_id_seq_owned_by.sql new file mode 100644 index 0000000000..725e9e968b --- /dev/null +++ b/modules/indicia_setup/db/version_8_23_2/202309211405_set_occurrences_id_seq_owned_by.sql @@ -0,0 +1 @@ +ALTER SEQUENCE occurrences_id_seq OWNED BY occurrences.id \ No newline at end of file diff --git a/modules/indicia_svc_spatial/controllers/services/spatial.php b/modules/indicia_svc_spatial/controllers/services/spatial.php index 2f475eddcc..10707b8307 100644 --- a/modules/indicia_svc_spatial/controllers/services/spatial.php +++ b/modules/indicia_svc_spatial/controllers/services/spatial.php @@ -1,7 +1,10 @@ spatial_ref::sref_to_internal_wkt($_GET['sref'], $_GET['system'])); - if (array_key_exists('mapsystem', $_GET)){ + $r = ['wkt' => spatial_ref::sref_to_internal_wkt($_GET['sref'], $_GET['system'])]; + if (array_key_exists('mapsystem', $_GET)) { $r['mapwkt'] = spatial_ref::internal_wkt_to_wkt($r['wkt'], $_GET['mapsystem']); } $r = json_encode($r); - // enable a JSONP request - if (array_key_exists('callback', $_GET)){ - $r = $_GET['callback']."(".$r.")"; + // Enable a JSONP request. + if (array_key_exists('callback', $_GET)) { + $r = "$_GET[callback]($r)"; + header('Content-Type: application/javascript; charset=utf-8'); } echo $r; } - catch (Exception $e) - { + catch (Exception $e) { $this->handle_error($e); } } /** + * Convert WKT format text to a spatial reference notation. + * * Handle a service request to convert a WKT representing the reference * using the internal SRID (normally spherical mercator since it is compatible with Google Maps) * into a spatial reference, though this can optionally be overriden by providing a wktsystem. @@ -59,22 +62,26 @@ public function sref_to_wkt() * degrees and minutes, or decimal degrees (default). * callback: For returning JSONP. */ - public function wkt_to_sref() - { - try - { - if (array_key_exists('precision',$_GET)) + public function wkt_to_sref() { + try { + if (array_key_exists('precision', $_GET)) { $precision = $_GET['precision']; - else - $precision = null; - if (array_key_exists('metresAccuracy',$_GET)) + } + else { + $precision = NULL; + } + if (array_key_exists('metresAccuracy', $_GET)) { $metresAccuracy = $_GET['metresAccuracy']; - else - $metresAccuracy = null; - if (array_key_exists('output',$_GET)) + } + else { + $metresAccuracy = NULL; + } + if (array_key_exists('output', $_GET)) { $output = $_GET['output']; - else - $output = null; + } + else { + $output = NULL; + } // Test/escape parameters that are passed in to queries to prevent // SQL injection. @@ -97,22 +104,22 @@ public function wkt_to_sref() $sref = spatial_ref::internal_wkt_to_sref($wkt, $_GET['system'], $precision, $output, $metresAccuracy); // Note we also need to return the wkt of the actual sref, which may be a square now. $wkt = spatial_ref::sref_to_internal_wkt($sref, $_GET['system']); - $r = array('sref' => $sref,'wkt' => $wkt); + $r = ['sref' => $sref,'wkt' => $wkt]; - if (array_key_exists('mapsystem', $_GET)){ + if (array_key_exists('mapsystem', $_GET)) { // Optionally output WKT of sref in mapsystem as well. $r['mapwkt'] = spatial_ref::internal_wkt_to_wkt($r['wkt'], $_GET['mapsystem']); } $r = json_encode($r); - // enable a JSONP request - if (array_key_exists('callback', $_GET)){ - $r = $_GET['callback']."(".$r.")"; + // Enable a JSONP request. + if (array_key_exists('callback', $_GET)) { + $r = "$_GET[callback]($r)"; + header('Content-Type: application/javascript; charset=utf-8'); } echo $r; } - catch (Exception $e) - { + catch (Exception $e) { $this->handle_error($e); } } @@ -128,10 +135,8 @@ public function wkt_to_sref() * expected to be accurate by. E.g.may be set according to the current zoom * scale of the map. Provided as an alternative to precision. */ - public function convert_sref() - { - try - { + public function convert_sref() { + try { // Test/escape parameters that are passed in to queries to prevent // SQL injection. // from_sref is not passed to query @@ -139,18 +144,21 @@ public function convert_sref() // to_systen us validated in internal_wkt_to_sref() // precision and metresAccuracy are not used in queries. $wkt = spatial_ref::sref_to_internal_wkt($_GET['from_sref'], $_GET['from_system']); - if (array_key_exists('precision',$_GET)) + if (array_key_exists('precision', $_GET)) { $precision = $_GET['precision']; - else - $precision = null; - if (array_key_exists('metresAccuracy',$_GET)) + } + else { + $precision = NULL; + } + if (array_key_exists('metresAccuracy', $_GET)) { $metresAccuracy = $_GET['metresAccuracy']; - else - $metresAccuracy = null; - echo spatial_ref::internal_wkt_to_sref($wkt, $_GET['to_system'], $precision, null, $metresAccuracy); + } + else { + $metresAccuracy = NULL; + } + echo spatial_ref::internal_wkt_to_sref($wkt, $_GET['to_system'], $precision, NULL, $metresAccuracy); } - catch (Exception $e) - { + catch (Exception $e) { $this->handle_error($e); } } @@ -183,7 +191,7 @@ public function buffer() { $r = $params['wkt']; } else { - $db = new Database; + $db = new Database(); // Test/escape parameters that are passed in to queries to prevent // SQL injection. $wkt = pg_escape_literal($db->getLink(), $params['wkt']); @@ -224,11 +232,11 @@ public function buffer() { } else { $r = 'No wkt or buffer to process'; } - if (array_key_exists('callback', $_REQUEST)) - { - $json=json_encode(array('response'=>$r)); - $r = $_REQUEST['callback']."(".$json.")"; - $this->content_type = 'Content-Type: application/javascript'; + // Enable a JSONP request. + if (array_key_exists('callback', $_REQUEST)) { + $json = json_encode(['response' => $r]); + $r = "$_REQUEST[callback]($json)"; + header('Content-Type: application/javascript; charset=utf-8'); } echo $r; }