Skip to content

Commit

Permalink
Merge pull request #5110 from 3liz/backport-5093-to-release_3_9
Browse files Browse the repository at this point in the history
[Backport release_3_9] [Bugfix] Edition : exec a DELETE can return 0 in some cases
  • Loading branch information
rldhont authored Dec 11, 2024
2 parents dcb33bd + e27be50 commit b9780e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lizmap/modules/lizmap/classes/qgisVectorLayer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,11 @@ public function updateFeature($feature, $values, $loginFilteredLayers)
* - attribute: filter attribute from the layer
* @param null|jDbConnection $connection DBConnection, if not null then the parameter conneciton is used, default value null
*
* @return int
* @return bool|int the number of affected rows. False if the query has failed.
*
* @throws Exception
*
* @see jDbConnection::exec() Launch a SQL Query (update, delete..) which doesn't return rows.
*/
public function deleteFeature($feature, $loginFilteredLayers, $connection = null)
{
Expand Down
2 changes: 1 addition & 1 deletion lizmap/modules/lizmap/controllers/edition.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ public function deleteFeature()
$feature = $this->featureData->features[0];
$rs = $qgisForm->deleteFromDb($feature, $cnx);

if ($rs) {
if ($rs !== false) {
jMessage::add(jLocale::get('view~edition.message.success.delete'), 'success');
$eventParams['deleteFiles'] = $deleteFiles;
$eventParams['success'] = true;
Expand Down
8 changes: 7 additions & 1 deletion lizmap/modules/lizmap/lib/Form/QgisForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,12 @@ protected function processWebDavUploadFile($form, $ref)
*
* @param mixed $feature
* @param null|\jDbConnection $cnx DBConnection, passed along QGISVectorLayer deleteFeature method
*
* @return bool|int the number of affected rows. False if the query has failed.
*
* @throws \Exception
*
* @see \jDbConnection::exec() Launch a SQL Query (update, delete..) which doesn't return rows.
*/
public function deleteFromDb($feature, $cnx = null)
{
Expand All @@ -1355,7 +1361,7 @@ public function deleteFromDb($feature, $cnx = null)
return 1;
}
if ($event->allResponsesByKeyAreFalse('cancelDelete') === false) {
return 0;
return false;
}
$result = $this->layer->deleteFeature($feature, $loginFilteredLayers, $cnx);
$this->appContext->eventNotify('LizmapEditionFeaturePostDelete', $eventParams);
Expand Down

0 comments on commit b9780e1

Please sign in to comment.