From 747c32426c7a0a8c7b56987c3abf3cd06dfe273e Mon Sep 17 00:00:00 2001 From: Dmitrii Fediuk Date: Mon, 4 Mar 2024 00:39:11 +0300 Subject: [PATCH] 10.6.5: https://github.com/mage2pro/core/issues/352 --- Core/lib/lang/other.php | 1 - Cron/lib/main.php | 1 - Qa/lib/validation/error.php | 37 +++++++++++++++++++++++++++++-------- composer.json | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Core/lib/lang/other.php b/Core/lib/lang/other.php index 1c4b8f70c..ac0125da6 100644 --- a/Core/lib/lang/other.php +++ b/Core/lib/lang/other.php @@ -23,7 +23,6 @@ function df_b(array $args, bool $r) {return !$args ? $r : $args[intval(!$r)];} * @see df_prop() * @see dfc() * @see dfcf() - * @used-by df_error() * @used-by df_sprintf_strict() * @used-by \Df\Qa\Failure\Error::log() */ diff --git a/Cron/lib/main.php b/Cron/lib/main.php index 64c6d071c..43692d2ed 100644 --- a/Cron/lib/main.php +++ b/Cron/lib/main.php @@ -4,7 +4,6 @@ * 2021-03-23 * A shorter solution would be df_area_code_is('crontab'), * but area code can be emulated: @see \Magento\Framework\App\State::emulateAreaCode() - * @used-by df_error() * @used-by \MageWorx\OptionBase\Helper\CustomerVisibility::isVisibilityFilterRequired() (canadasatellite.ca, https://github.com/canadasatellite-ca/site/issues/35) */ function df_is_cron():bool {return df_is_bin_magento() && 'cron:run' === df_cli_argv(1);} \ No newline at end of file diff --git a/Qa/lib/validation/error.php b/Qa/lib/validation/error.php index 573aa7656..d7ef14291 100644 --- a/Qa/lib/validation/error.php +++ b/Qa/lib/validation/error.php @@ -151,7 +151,7 @@ function df_abstract($caller):void { */ function df_error(...$a):void { df_header_utf(); - $e = df_error_create(...$a); /** @var DFE $e */ + throw df_error_create(...$a); /** * 2020-02-15 * 1) "The Cron log (`magento.cron.log`) should contain a backtrace for every exception logged": @@ -160,14 +160,35 @@ function df_error(...$a):void { * https://3v4l.org/qhd7m * So we have a correct backtrace even without throwing the exception. * 2020-02-17 @see \Df\Cron\Plugin\Console\Command\CronCommand::aroundRun() + * 2024-03-03 + * 1) "An endless loop `df_error` → `df_log` → … → `df_module_file_name` → … → `df_error`": + * https://github.com/mage2pro/core/issues/353 + * 2) The previous code: + * if (df_is_cron()) { + * df_no_rec(function() use($e):void {df_log($e, 'Df_Cron');}); + * } + * https://github.com/mage2pro/core/blob/10.6.4/Qa/lib/validation/error.php#L164-L169 + * 3) We do not need to log the exception here because it will be logged in 2 places: + * 3.1) @see \Df\Cron\Plugin\Console\Command\CronCommand::aroundRun() + * https://github.com/mage2pro/core/blob/10.6.4/Cron/Plugin/Console/Command/CronCommand.php#L19-L27 + * 3.2) @see \Magento\Framework\Console\Cli::doRun(): + * try { + * $exitCode = parent::doRun($input, $output); + * } + * catch (\Exception $e) { + * $errorMessage = $e->getMessage() . PHP_EOL . $e->getTraceAsString(); + * $this->logger->error($errorMessage); + * $this->initException = $e; + * } + * https://github.com/magento/magento2/blob/2.4.7-beta2/lib/internal/Magento/Framework/Console/Cli.php#L115-L121 + * `$this->logger->error($errorMessage);` will be logged by @see \Df\Framework\Log\Dispatcher::handle() + * 4) "The required file «vendor/mage2pro/core/Cron/etc/df.json» is absent": + * https://github.com/mage2pro/core/issues/352 + * @see df_module_file_name() + * https://github.com/mage2pro/core/blob/10.6.4/Framework/lib/module/fs/name.php#L79-L84 + * This error should not be logged at all, because `df_module_file_name()` is called with `$onE = false`, + * and `Df_Core` module is used instead of `Df_Cron`: @see df_sentry_m(). */ - if (df_is_cron()) { - # 2024-03-03 - # "An endless loop `df_error` → `df_log` → … → `df_module_file_name` → … → `df_error`": - # https://github.com/mage2pro/core/issues/353 - df_no_rec(function() use($e):void {df_log($e, 'Df_Cron');}); - } - throw $e; } /** diff --git a/composer.json b/composer.json index 17d632fb0..c0006fe61 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mage2pro/core" - ,"version": "10.6.4" + ,"version": "10.6.5" ,"description": "Mage2.PRO core package." ,"type": "magento2-module" ,"homepage": "https://mage2.pro"