Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some filenames can be lost in log file selection list #2627

Closed
ddb4github opened this issue Apr 13, 2019 · 4 comments
Closed

Some filenames can be lost in log file selection list #2627

ddb4github opened this issue Apr 13, 2019 · 4 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@ddb4github
Copy link
Contributor

array plus(+) operator will ignore some item with same key, even key is just serial no like 0, 1
So the first two file of $stdLogFileArray is always ignore.

--- lib/clog_webapi.php 2019-03-31 02:45:32.000000000 +0800
+++ lib/clog_webapi.php       2019-04-13 12:43:37.707854996 +0800
@@ -467,7 +467,8 @@
                                                arsort($stdLogFileArray, SORT_NATURAL);
                                                arsort($stdErrFileArray, SORT_NATURAL);

-                                               $logFileArray = $stdFileArray + $stdLogFileArray + $stdErrFileArray;
+                                               sort($stdLogFileArray);
+                                               $logFileArray = array_merge($stdFileArray, $stdLogFileArray, $stdErrFileArray);

                                                if (cacti_sizeof($logFileArray)) {
                                                        foreach ($logFileArray as $logFile) {
@netniV
Copy link
Member

netniV commented Apr 15, 2019

You are changing the sort order and losing the keys by using sort over arsort if I remember rightly (haven't double checked the functions on php.net)

@ddb4github
Copy link
Contributor Author

cacti_log_missed_and_order

--- cacti/lib/clog_webapi.php        2019-04-16 10:46:17.211593816 +0800
+++ cacti/lib/clog_webapi.php      2019-04-16 10:45:23.904577824 +0800
@@ -426,9 +426,14 @@
                                                                        continue;
                                                                }

+                                                               if(strpos($logFile, $stderrLogBase) === 0){
+                                                                       $stdErrFileArray[] = $logFile;
+                                                               } else {
                                                                $stdLogFileArray[] = $logFile;
                                                        }
+                                                       }

+                                                       $stdErrFileArray = array_unique($stdErrFileArray);
                                                        $stdLogFileArray = array_unique($stdLogFileArray);
                                                }

@@ -467,7 +472,7 @@
                                                arsort($stdLogFileArray, SORT_NATURAL);
                                                arsort($stdErrFileArray, SORT_NATURAL);

-                                               $logFileArray = $stdFileArray + $stdLogFileArray + $stdErrFileArray;
+                                               $logFileArray = array_merge($stdFileArray, $stdLogFileArray, $stdErrFileArray);

                                                if (cacti_sizeof($logFileArray)) {
                                                        foreach ($logFileArray as $logFile) {

@netniV
Copy link
Member

netniV commented Apr 16, 2019

OK, that seems to make more sense.

cigamit added a commit that referenced this issue Apr 17, 2019
Lost partial log files name in Logs(tab)->File(filter selector)
@cigamit cigamit added bug Undesired behaviour resolved A fixed issue labels Apr 17, 2019
@cigamit cigamit added this to the v1.2.4 milestone Apr 17, 2019
@cigamit
Copy link
Member

cigamit commented Apr 17, 2019

This is resolved now.

@cigamit cigamit closed this as completed Apr 25, 2019
@netniV netniV changed the title Lost partial log files name in Logs(tab)->File(filter selector) Some filenames can be lost in log file selection list Apr 28, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

3 participants