mirror of
https://github.com/friendica/friendica
synced 2024-12-23 05:20:15 +00:00
Changes:
- some methods now need to return bool to be compatible - added some missing type-hints
This commit is contained in:
parent
9c80dd35e5
commit
cc750d743b
1 changed files with 10 additions and 9 deletions
|
@ -33,7 +33,7 @@ class ExtendedPDO extends PDO
|
||||||
/**
|
/**
|
||||||
* @var array Database drivers that support SAVEPOINT * statements.
|
* @var array Database drivers that support SAVEPOINT * statements.
|
||||||
*/
|
*/
|
||||||
protected static $_supportedDrivers = ["pgsql", "mysql"];
|
protected static $_supportedDrivers = ['pgsql', 'mysql'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int the current transaction depth
|
* @var int the current transaction depth
|
||||||
|
@ -80,9 +80,9 @@ class ExtendedPDO extends PDO
|
||||||
/**
|
/**
|
||||||
* Commit current transaction
|
* Commit current transaction
|
||||||
*
|
*
|
||||||
* @return bool|void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function commit()
|
public function commit(): bool
|
||||||
{
|
{
|
||||||
// We don't want to "really" commit something, so skip the most outer hierarchy
|
// We don't want to "really" commit something, so skip the most outer hierarchy
|
||||||
if ($this->_transactionDepth <= 1 && $this->hasSavepoint()) {
|
if ($this->_transactionDepth <= 1 && $this->hasSavepoint()) {
|
||||||
|
@ -92,28 +92,29 @@ class ExtendedPDO extends PDO
|
||||||
|
|
||||||
$this->_transactionDepth--;
|
$this->_transactionDepth--;
|
||||||
|
|
||||||
$this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}");
|
return $this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback current transaction,
|
* Rollback current transaction,
|
||||||
*
|
*
|
||||||
* @throws PDOException if there is no transaction started
|
* @throws PDOException if there is no transaction started
|
||||||
* @return bool|void
|
* @return bool Whether rollback was successful
|
||||||
*/
|
*/
|
||||||
public function rollBack()
|
public function rollback(): bool
|
||||||
{
|
{
|
||||||
$this->_transactionDepth--;
|
$this->_transactionDepth--;
|
||||||
|
|
||||||
if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
|
if ($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
|
||||||
$this->_transactionDepth = 0;
|
$this->_transactionDepth = 0;
|
||||||
try {
|
try {
|
||||||
parent::rollBack();
|
return parent::rollBack();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
// this shouldn't happen, but it does ...
|
// this shouldn't happen, but it does ...
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}");
|
return $this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}");
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue