Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release_3_8] [Bugfix] Edition : exec a DELETE can return 0 in some cases #5109

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1291,6 +1291,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 @@ -1316,7 +1322,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
Loading