when deleting multiple events, each event has to be it's own transaction due to locking
This commit is contained in:
parent
f1cffa6fe1
commit
8103156436
|
@ -142,16 +142,14 @@ class Event extends ZM_Object {
|
||||||
# Assumption: All events have a start time
|
# Assumption: All events have a start time
|
||||||
$start_date = date_parse($this->{'StartTime'});
|
$start_date = date_parse($this->{'StartTime'});
|
||||||
if ( ! $start_date ) {
|
if ( ! $start_date ) {
|
||||||
Error('Unable to parse start time for event ' . $this->{'Id'} . ' not deleting files.');
|
throw new Exception('Unable to parse start time for event ' . $this->{'Id'} . ' not deleting files.');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$start_date['year'] = $start_date['year'] % 100;
|
$start_date['year'] = $start_date['year'] % 100;
|
||||||
|
|
||||||
# So this is because ZM creates a link under the day pointing to the time that the event happened.
|
# So this is because ZM creates a link under the day pointing to the time that the event happened.
|
||||||
$link_path = $this->Link_Path();
|
$link_path = $this->Link_Path();
|
||||||
if ( ! $link_path ) {
|
if ( ! $link_path ) {
|
||||||
Error('Unable to determine link path for event '.$this->{'Id'}.' not deleting files.');
|
throw new Exception('Unable to determine link path for event '.$this->{'Id'}.' not deleting files.');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$Storage = $this->Storage();
|
$Storage = $this->Storage();
|
||||||
|
@ -159,8 +157,7 @@ class Event extends ZM_Object {
|
||||||
|
|
||||||
if ( $id_files = glob($eventlink_path) ) {
|
if ( $id_files = glob($eventlink_path) ) {
|
||||||
if ( ! $eventPath = readlink($id_files[0]) ) {
|
if ( ! $eventPath = readlink($id_files[0]) ) {
|
||||||
Error("Unable to read link at $id_files[0]");
|
throw new Exception("Unable to read link at $id_files[0]");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
# I know we are using arrays here, but really there can only ever be 1 in the array
|
# I know we are using arrays here, but really there can only ever be 1 in the array
|
||||||
$eventPath = preg_replace('/\.'.$this->{'Id'}.'$/', $eventPath, $id_files[0]);
|
$eventPath = preg_replace('/\.'.$this->{'Id'}.'$/', $eventPath, $id_files[0]);
|
||||||
|
@ -179,8 +176,7 @@ class Event extends ZM_Object {
|
||||||
} else {
|
} else {
|
||||||
$eventPath = $this->Path();
|
$eventPath = $this->Path();
|
||||||
if ( ! $eventPath ) {
|
if ( ! $eventPath ) {
|
||||||
Error('No event Path in Event delete. Not deleting');
|
throw new Exception('No event Path in Event delete. Not deleting');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
deletePath($eventPath);
|
deletePath($eventPath);
|
||||||
if ( $this->SecondaryStorageId() ) {
|
if ( $this->SecondaryStorageId() ) {
|
||||||
|
@ -199,6 +195,9 @@ class Event extends ZM_Object {
|
||||||
$dbConn->commit();
|
$dbConn->commit();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
$dbConn->rollback();
|
$dbConn->rollback();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Error($e->getMessage());
|
||||||
|
$dbConn->rollback();
|
||||||
}
|
}
|
||||||
} # end Event->delete
|
} # end Event->delete
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,9 @@ if ( $action == 'archive' ) {
|
||||||
$dbConn->commit();
|
$dbConn->commit();
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
} else if ( $action == 'delete' ) {
|
} else if ( $action == 'delete' ) {
|
||||||
$dbConn->beginTransaction();
|
|
||||||
foreach ( getAffectedIds('eids') as $markEid ) {
|
foreach ( getAffectedIds('eids') as $markEid ) {
|
||||||
deleteEvent($markEid);
|
deleteEvent($markEid);
|
||||||
}
|
}
|
||||||
$dbConn->commit();
|
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue