Added a check for the existence of logs folder. Do not report about abandoned carts state in logs

This commit is contained in:
max-baranikov 2021-06-21 16:39:50 +03:00 committed by GitHub
parent 49f687f6ff
commit 5fc6e4c5b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -210,9 +210,14 @@ class RetailcrmLogger
public static function clearObsoleteLogs()
{
$logDir = self::getLogDir();
if (!is_dir($logDir)) {
return;
}
$handle = opendir($logDir);
while (($file = readdir($handle)) !== false) {
if (false !== self::checkFileName($file)) {
if (self::checkFileName($file) !== false) {
$path = "$logDir/$file";
if (filemtime($path) < strtotime('-30 days')) {
unlink($path);
@ -226,9 +231,13 @@ class RetailcrmLogger
$fileNames = [];
$logDir = self::getLogDir();
if (!is_dir($logDir)) {
return;
}
$handle = opendir($logDir);
while (false !== $file = readdir($handle)) {
if (false !== self::checkFileName($file)) {
while ($file = readdir($handle) !== false) {
if (self::checkFileName($file) !== false) {
$path = "$logDir/$file";
$fileNames[] = [
'name' => $file,

View file

@ -63,7 +63,7 @@ class RetailcrmAbandonedCartsEvent extends RetailcrmAbstractEvent implements Ret
$syncCartsActive = Configuration::get(RetailCRM::SYNC_CARTS_ACTIVE);
if (empty($syncCartsActive)) {
RetailcrmLogger::writeCaller(__METHOD__, 'Abandoned carts is disabled, skipping...');
RetailcrmLogger::writeDebug(__METHOD__, 'Abandoned carts is disabled, skipping...');
continue;
}