Skip to content

Commit

Permalink
migxresourcemediapath fix debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno17 committed Jan 21, 2023
1 parent c2b9e1d commit b4086c3
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -32,6 +32,8 @@
$createpath = false;
$defaultpath = $modx->getOption('defaultPath', $scriptProperties, 'assets/migxdefault/');

$debug = (bool)$modx->getOption('debug');

if (empty($pathTpl)) {
if ($modx->getDebug() === true) {
$modx->log(MODX_LOG_LEVEL_ERROR, '[migxResourceMediaPath]: pathTpl not specified.');
Expand Down Expand Up @@ -71,7 +73,7 @@
}

if (empty($docid)) {
if ($modx->getDebug() === true) {
if ($debug) {
$modx->log(MODX_LOG_LEVEL_ERROR, '[migxResourceMediaPath]: docid could not be determined.');
}
return $defaultpath;
Expand Down Expand Up @@ -141,7 +143,7 @@

$permissions = octdec('0' . (int)($modx->getOption('new_folder_permissions', null, '755', true)));
if (!@mkdir($fullpath, $permissions, true)) {
if ($modx->getDebug() === true) {
if ($debug) {
$modx->log(MODX_LOG_LEVEL_ERROR, sprintf('[migxResourceMediaPath]: could not create directory %s).', $fullpath));
}
} else {
Expand All @@ -151,7 +153,7 @@

return $path;
} else {
if ($modx->getDebug() === true) {
if ($debug) {
$modx->log(MODX_LOG_LEVEL_ERROR, sprintf('[migxResourceMediaPath]: resource not found (page id %s).', $docid));
}
return $defaultpath;
Expand Down

0 comments on commit b4086c3

Please sign in to comment.