privUITransaction fix inspections errors + formatting

This commit is contained in:
Pierre Goiffon
2021-10-12 16:56:15 +02:00
parent 92a9a8c65f
commit 34f64c61f6

View File

@@ -26,8 +26,6 @@
* @copyright Copyright (C) 2010-2012 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
class privUITransaction
{
/**
@@ -101,7 +99,6 @@ class privUITransaction
/**
* The original (and by default) mechanism for storing transaction information
* as an array in the $_SESSION variable
*
*/
class privUITransactionSession
{
@@ -207,6 +204,7 @@ class privUITransactionFile
{
throw new Exception('The directory "'.APPROOT.'data" must be writable to the application.');
}
/** @noinspection MkdirRaceConditionInspection */
if (!@mkdir(APPROOT.'data/transactions'))
{
throw new Exception('Failed to create the directory "'.APPROOT.'data/transactions". Ajust the rights on the parent directory or let an administrator create the transactions directory and give the web sever enough rights to write into it.');
@@ -268,27 +266,26 @@ class privUITransactionFile
/**
* Removes the transaction specified by its id
* @param int $id The Identifier (as returned by GetNewTransactionId) of the transaction to be removed.
* @return void
* @return bool true if the token can be removed
*/
public static function RemoveTransaction($id)
{
$bSuccess = true;
$sFilepath = APPROOT.'data/transactions/'.$id;
clearstatcache(true, $sFilepath);
if(!file_exists($sFilepath))
{
if (!file_exists($sFilepath)) {
$bSuccess = false;
self::Error("RemoveTransaction: Transaction '$id' not found. Pending transactions for this user:\n".implode("\n", self::GetPendingTransactions()));
self::Error("RemoveTransaction: Transaction '$id' not found. Pending transactions for this user:\n"
.implode("\n", self::GetPendingTransactions()));
} else {
$bSuccess = @unlink($sFilepath);
}
$bSuccess = @unlink($sFilepath);
if (!$bSuccess)
{
if (!$bSuccess) {
self::Error('RemoveTransaction: FAILED to remove transaction '.$id);
}
else
{
} else {
self::Info('RemoveTransaction: OK '.$id);
}
return $bSuccess;
}