Skip to content

Commit

Permalink
N°4289 Fix privUITransactionFile generating error if MetaModel not lo…
Browse files Browse the repository at this point in the history
…aded
  • Loading branch information
Pierre Goiffon committed Oct 20, 2021
1 parent 723eb90 commit a353317
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions application/transaction.class.inc.php
Expand Up @@ -100,7 +100,7 @@ public static function RemoveTransaction($id)
* The original mechanism for storing transaction information as an array in the $_SESSION variable
*
* Warning, since 2.6.0 the session is regenerated on each login (see PR #20) !
* Also, we saw some problems when using memcached as the PHP session implementation (see N°1835)
* Also, we saw some problems when using memcached as the PHP session implementation (see N°1835)
*/
class privUITransactionSession
{
Expand Down Expand Up @@ -353,22 +353,35 @@ protected static function Error($sText)
{
self::Write('Error | '.$sText);
}


protected static function IsLogEnabled() {
$oConfig = MetaModel::GetConfig();
if (is_null($oConfig)) {
return false;
}

$bLogTransactions = $oConfig->Get('log_transactions');
if (true === $bLogTransactions) {
return true;
}

return false;
}

protected static function Write($sText)
{
$bLogEnabled = MetaModel::GetConfig()->Get('log_transactions');
if ($bLogEnabled)
{
if (false === static::IsLogEnabled()) {
return;
}

$hLogFile = @fopen(APPROOT.'log/transactions.log', 'a');
if ($hLogFile !== false)
{
if ($hLogFile !== false) {
flock($hLogFile, LOCK_EX);
$sDate = date('Y-m-d H:i:s');
fwrite($hLogFile, "$sDate | $sText\n");
fflush($hLogFile);
flock($hLogFile, LOCK_UN);
fclose($hLogFile);
}
}
}
}

0 comments on commit a353317

Please sign in to comment.