mirror of
https://github.com/Cacti/plugin_thold.git
synced 2026-10-23 03:27:05 +09:00
fix(import): log the current template error instead of a stale success (#856)
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
This commit is contained in:
1 parent
6bbfb58492
commit
2de8e1c7eb
3 files changed
+37
-1
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
## ChangeLog
|
## ChangeLog
|
||||||
|
|
||||||
--- develop ---
|
--- develop ---
|
||||||
|
* issue: Log each template import error using its own message (#757)
|
||||||
* bug: Element-qualify the `.thold-pill` CSS so it outranks the single-class theme rules (e.g. `.deviceUpFull` `width:14%`) that were clipping the pill to a fixed width; status pills now size to their label on the Device Status page and everywhere else
|
* bug: Element-qualify the `.thold-pill` CSS so it outranks the single-class theme rules (e.g. `.deviceUpFull` `width:14%`) that were clipping the pill to a fixed width; status pills now size to their label on the Device Status page and everywhere else
|
||||||
* feature: Clicking an already-selected status pill now clears that filter (resets to All) instead of re-applying it, on the Thresholds, Device Status and Threshold Log sub-tabs
|
* feature: Clicking an already-selected status pill now clears that filter (resets to All) instead of re-applying it, on the Thresholds, Device Status and Threshold Log sub-tabs
|
||||||
* bug: Pass a boolean (not the integer `1`) to `api_plugin_register_hook()`'s `$enable` argument so the hook registration stays type-correct under Cacti 1.3's strict `bool $enable` type-hint (the int only coerces while this file lacks `declare(strict_types=1)`)
|
* bug: Pass a boolean (not the integer `1`) to `api_plugin_register_hook()`'s `$enable` argument so the hook registration stays type-correct under Cacti 1.3's strict `bool $enable` type-hint (the int only coerces while this file lacks `declare(strict_types=1)`)
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
+-------------------------------------------------------------------------+
|
||||||
|
| Copyright (C) 2004-2026 The Cacti Group |
|
||||||
|
| |
|
||||||
|
| This program is free software; you can redistribute it and/or |
|
||||||
|
| modify it under the terms of the GNU General Public License |
|
||||||
|
| as published by the Free Software Foundation; either version 2 |
|
||||||
|
| of the License, or (at your option) any later version. |
|
||||||
|
+-------------------------------------------------------------------------+
|
||||||
|
| Cacti: The Complete RRDtool-based Graphing Solution |
|
||||||
|
+-------------------------------------------------------------------------+
|
||||||
|
| http://www.cacti.net/ |
|
||||||
|
+-------------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Regression for template error logs reusing a previous success message. */
|
||||||
|
final class TemplateImportErrorLoggingTest extends TestCase {
|
||||||
|
public function testEachImportErrorUsesItsOwnMessage(): void {
|
||||||
|
$source = file_get_contents(dirname(__DIR__, 2) . '/thold_templates.php');
|
||||||
|
preg_match('/foreach \(\$return_data\[\'errors\'\] as \$error\) \{(.*?)\n\t\t\}/s', $source, $loop);
|
||||||
|
$this->assertNotEmpty($loop);
|
||||||
|
$return_data = ['errors' => ['missing field', 'invalid template']];
|
||||||
|
$message = 'previous success';
|
||||||
|
$debug_data = [];
|
||||||
|
// Run the production loop body using the existing logging recorder.
|
||||||
|
foreach ($return_data['errors'] as $error) {
|
||||||
|
eval($loop[1]);
|
||||||
|
}
|
||||||
|
$this->assertSame([
|
||||||
|
'NOTE: Template Import Error!. Message: missing field',
|
||||||
|
'NOTE: Template Import Error!. Message: invalid template',
|
||||||
|
], CactiStubs::$log);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -2718,7 +2718,7 @@ function template_import() {
|
|||||||
if (isset($return_data['errors'])) {
|
if (isset($return_data['errors'])) {
|
||||||
foreach ($return_data['errors'] as $error) {
|
foreach ($return_data['errors'] as $error) {
|
||||||
$debug_data[] = '<span class="deviceDown">' . __('ERROR:', 'thold') . '</span> ' . $error;
|
$debug_data[] = '<span class="deviceDown">' . __('ERROR:', 'thold') . '</span> ' . $error;
|
||||||
cacti_log('NOTE: Template Import Error!. Message: ' . $message, false, 'THOLD');
|
cacti_log('NOTE: Template Import Error!. Message: ' . $error, false, 'THOLD');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user