Skip to content

Commit 736ee46

Browse files
author
markus-moser
committed
Activity persistance bugfixes
1 parent 9d4ec23 commit 736ee46

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/ActivityStore/MariaDb.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function updateActivityStoreEntry(ActivityStoreEntryInterface $entry, $up
8787
$this->saveActivityStoreEntry($entry, $activity);
8888
}
8989

90-
throw new \Exception('related activity not found - updating attributes failed');
90+
$this->saveActivityStoreEntry($entry);
9191
}
9292

9393
protected function saveActivityStoreEntry(ActivityStoreEntryInterface $entry, ActivityInterface $activity = null)
@@ -99,18 +99,23 @@ protected function saveActivityStoreEntry(ActivityStoreEntryInterface $entry, Ac
9999
unset($data['attributes']);
100100
if (!is_null($activity)) {
101101
$data['attributes'] = $this->getActivityAttributeDataAsDynamicColumnInsert($activity);
102+
$data['type'] = $db->quote($activity->cmfGetType());
103+
$data['implementationClass'] = $db->quote(get_class($activity));
104+
} else {
105+
$data['type'] = $db->quote($data['type']);
106+
$data['implementationClass'] = $db->quote($data['implementationClass']);
102107
}
103108

104-
$data['type'] = $db->quote($activity->cmfGetType());
105-
$data['implementationClass'] = $db->quote(get_class($activity));
106109
$data['a_id'] = $db->quote($data['a_id']);
107110

108111
if ($activity instanceof ActivityExternalIdInterface) {
109112
$data['a_id'] = $db->quote($activity->getId());
110113
}
111114

115+
$data['customerId'] = !is_null($activity) ? $activity->getCustomer()->getId() : $entry->getCustomerId();
116+
112117
$md5Data = [
113-
'customerId' => $activity->getCustomer()->getId(),
118+
'customerId' => $data['customerId'],
114119
'type' => $data['type'],
115120
'implementationClass' => $data['implementationClass'],
116121
'o_id' => $data['o_id'],

src/Model/ActivityList/DefaultMariaDbActivityList/Dao.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ protected function addConditions(Db\ZendCompatibility\QueryBuilder $select)
128128
$condition = $this->model->getCondition();
129129

130130
if ($condition) {
131-
$select->where($condition, $this->model->getConditionVariables());
131+
if($conditionVariables = $this->model->getConditionVariables()) {
132+
$select->where($condition, $conditionVariables);
133+
} else {
134+
$select->where($condition);
135+
}
132136
}
133137

134138
return $this;

src/Model/ActivityStoreEntry/DefaultActivityStoreEntry.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ public function getData()
319319
public function save($updateAttributes = false)
320320
{
321321
$relatedItem = $this->getRelatedItem();
322-
$relatedItem->setCustomer($this->getCustomer());
323-
\Pimcore::getContainer()->get('cmf.activity_store')->updateActivityStoreEntry($this, $updateAttributes);
322+
if($relatedItem) {
323+
$relatedItem->setCustomer($this->getCustomer());
324+
}
325+
326+
\Pimcore::getContainer()->get('cmf.activity_store')->updateActivityStoreEntry($this, $relatedItem ? $updateAttributes : false);
324327
}
325328
}

0 commit comments

Comments
 (0)