From 03bf7b80af7a3a14cfd3f5938ad80f1e2b19addc Mon Sep 17 00:00:00 2001 From: rldhont Date: Wed, 11 Oct 2023 15:09:00 +0200 Subject: [PATCH] [Bugfix] Check Geometry Edition constraint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases, like editable view, the geometry value is not well retrived and check. Funded by Conseil Départemental du Calvados --- lizmap/modules/lizmap/classes/qgisVectorLayer.class.php | 4 ++-- lizmap/modules/lizmap/lib/Form/QgisForm.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lizmap/modules/lizmap/classes/qgisVectorLayer.class.php b/lizmap/modules/lizmap/classes/qgisVectorLayer.class.php index 40d65ffc94..ac5081e773 100644 --- a/lizmap/modules/lizmap/classes/qgisVectorLayer.class.php +++ b/lizmap/modules/lizmap/classes/qgisVectorLayer.class.php @@ -704,7 +704,7 @@ public function checkFeatureAgainstPolygonFilter($values) return false; } catch (Exception $e) { - jLog::log('Project '.$this->project->getKey().' layer '.$this->name.': bad SQL query to check feature against polygon filter : '.$sql, 'lizmapadmin'); + \jLog::log('Project '.$this->project->getKey().' layer '.$this->name.': bad SQL query to check feature against polygon filter : '.$sql, 'lizmapadmin'); throw $e; } @@ -807,7 +807,7 @@ public function insertFeature($values) return $pkvals; } catch (Exception $e) { - jLog::log('Project '.$this->project->getKey().' layer '.$this->name.': bad SQL query to insert a feature :'.$sql, 'lizmapadmin'); + \jLog::log('Project '.$this->project->getKey().' layer '.$this->name.': bad SQL query to insert a feature :'.$sql, 'lizmapadmin'); throw $e; } diff --git a/lizmap/modules/lizmap/lib/Form/QgisForm.php b/lizmap/modules/lizmap/lib/Form/QgisForm.php index 6af939c3ce..9f14a5d1da 100644 --- a/lizmap/modules/lizmap/lib/Form/QgisForm.php +++ b/lizmap/modules/lizmap/lib/Form/QgisForm.php @@ -589,6 +589,10 @@ public function check($feature = null) $constraintExpressions[$fieldName] = $constraints['exp_value']; } } + // Get geometry from form if already set + if ($geometryColumn != '' && $values[$geometryColumn] == null) { + $values[$geometryColumn] = $form->getData($geometryColumn); + } // Check the geometry is inside the filtering polygons, if relevant $geomInPolygon = $this->layer->checkFeatureAgainstPolygonFilter($values);