Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(TB Relations related_record) prevent rollbacks when not desired
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmhh committed Apr 13, 2021
1 parent e761a4e commit 08fc18b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion tine20/Tinebase/Relations.php
Expand Up @@ -5,7 +5,7 @@
* @package Tinebase
* @subpackage Relations
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @copyright Copyright (c) 2008-2018 Metaways Infosystems GmbH (http://www.metaways.de)
* @copyright Copyright (c) 2008-2021 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Cornelius Weiss <c.weiss@metaways.de>
*
* @todo re-enable the caching (but check proper invalidation first) -> see task #232
Expand Down Expand Up @@ -565,7 +565,9 @@ protected function _setAppRecord($_relation, $_doCreateUpdateCheck = false)
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
. ' Don\'t update related record because user has no update grant');
} else {
$oldRollback = Tinebase_TransactionManager::getInstance()->unitTestForceSkipRollBack();
try {
Tinebase_TransactionManager::getInstance()->unitTestForceSkipRollBack(true);
/** @var Tinebase_Record_Interface $record */
$record = $appController->$method($_relation->related_record,
$_doCreateUpdateCheck && $this->_doCreateUpdateCheck($_relation));
Expand All @@ -574,6 +576,11 @@ protected function _setAppRecord($_relation, $_doCreateUpdateCheck = false)
// some right might prevent the update ... skipping update
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
. ' Don\'t update related record: ' . $tead->getMessage());
} catch (Tinebase_Exception_NotFound $tenf) {
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__
. ' Don\'t update related record: ' . $tenf->getMessage());
} finally {
Tinebase_TransactionManager::getInstance()->unitTestForceSkipRollBack($oldRollback);
}
}

Expand Down
7 changes: 6 additions & 1 deletion tine20/Tinebase/TransactionManager.php
Expand Up @@ -292,9 +292,14 @@ public function hasOpenTransactions()
/**
* @param $bool
*/
public function unitTestForceSkipRollBack($bool)
public function unitTestForceSkipRollBack($bool = null)
{
$this->_unitTestForceSkipRollBack = $bool;
$oldValue = $this->_unitTestForceSkipRollBack;
if (null !== $bool) {
$this->_unitTestForceSkipRollBack = $bool;
}
return $oldValue;
}

public function unitTestRemoveTransactionable($_transactionable)
Expand Down

0 comments on commit 08fc18b

Please sign in to comment.