Skip to content

Commit

Permalink
debug: check core config file to decide if clockwork should be turned…
Browse files Browse the repository at this point in the history
… on (#5113)
  • Loading branch information
bloep committed Apr 15, 2022
1 parent 4b35b5d commit da96794
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion redaxo/src/addons/debug/boot.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

if (!rex::isDebugMode() || 'debug' === rex_get(rex_api_function::REQ_CALL_PARAM)) {
if (!rex_debug_clockwork::isRexDebugEnabled() || 'debug' === rex_get(rex_api_function::REQ_CALL_PARAM)) {
return;
}

Expand Down
18 changes: 18 additions & 0 deletions redaxo/src/addons/debug/lib/debug_clockwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,22 @@ public static function getStoragePath()
{
return rex_addon::get('debug')->getCachePath('clockwork.db');
}

/**
* We cannot rely on rex::isDebugMode() because it is always true on the console.
* So we have to check the config file itself.
*/
public static function isRexDebugEnabled(): bool
{
if (PHP_SAPI !== 'cli') {
return rex::isDebugMode();
}

$coreConfigCacheFile = rex_path::coreCache('config.yml.cache');
$coreConfigCache = rex_file::getCache($coreConfigCacheFile);
/** @var bool $debugEnabled */
$debugEnabled = $coreConfigCache['debug']['enabled'] ?? false;

return $debugEnabled;
}
}

0 comments on commit da96794

Please sign in to comment.