PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.7.2
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.7.2
2.7.1 2.7.2 2.7.0 2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 All 141 releases
← All changes | includes/class-metasync-errorlogs.php +24 -16 2.7.0 → 2.7.2 View file →
@@ -28,13 +28,13 @@
28 28 $tail_bytes = 1024 * 1024;
29 29 $size = filesize($logFilePath);
30 30 $content = false;
31 31 if (false !== $size && $size > $tail_bytes) {
32 - $handle = @fopen($logFilePath, 'rb');
32 + $handle = @fopen($logFilePath, 'rb'); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- streaming file I/O; WP_Filesystem cannot return a raw stream handle
33 33 if (false !== $handle) {
34 34 fseek($handle, $size - $tail_bytes);
35 35 $content = stream_get_contents($handle);
36 - fclose($handle);
36 + fclose($handle); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- operates on a native stream handle
37 37 // Drop the leading partial line the window cut into.
38 38 if (false !== $content && false !== strpos($content, "\n")) {
39 39 $content = substr($content, strpos($content, "\n") + 1);
40 40 }
@@ -49,9 +49,9 @@
49 49 $logFileHandle = explode("\n", $content);
50 50
51 51 foreach ($logFileHandle as $id => $currentLine) {
52 52 // Normal error log line starts with the date & time in []
53 - if ('[' === @$currentLine[0]) {
53 + if ('[' === ($currentLine[0] ?? '')) {
54 54 // if (10000 === \count($parsedLogs)) {
55 55 // return $parsedLogs;
56 56 // }
57 57
@@ -128,24 +128,32 @@
128 128 'stackTrace' => []
129 129 ];
130 130 } // Stack trace beginning line
131 131 else if ('Stack trace:' === $currentLine) {
132 + $parsedLogsLastKey = array_key_last($parsedLogs);
133 + if (null === $parsedLogsLastKey) {
134 + continue;
135 + }
136 +
132 137 $stackTraceLineNumber = 0;
133 -
134 - foreach ($logFileHandle as $line) {
135 - $currentLine = str_replace(PHP_EOL, '', $line);
136 -
137 - // If the current line is a stack trace line
138 - if ('#' === $currentLine[0]) {
139 - $parsedLogsLastKey = key($parsedLogs);
140 - $currentLine = str_replace('#' . $stackTraceLineNumber, '', $currentLine);
141 - $parsedLogs[$parsedLogsLastKey]['stackTrace'][] = trim($currentLine);
142 -
138 + for ($trace_index = $id + 1, $trace_count = count($logFileHandle); $trace_index < $trace_count; $trace_index++) {
139 + $trace_line = trim($logFileHandle[$trace_index]);
140 + if ('' === $trace_line) {
141 + continue;
142 + }
143 + if ('#' === $trace_line[0]) {
144 + $prefix = '#' . $stackTraceLineNumber;
145 + if (0 === strpos($trace_line, $prefix)) {
146 + $trace_line = substr($trace_line, strlen($prefix));
147 + }
148 + $parsedLogs[$parsedLogsLastKey]['stackTrace'][] = trim($trace_line);
143 149 $stackTraceLineNumber++;
144 - } // If the current line is the last stack trace ('thrown in...')
145 - else {
146 - break;
150 + continue;
147 151 }
152 + if (0 === strpos($trace_line, 'thrown in ')) {
153 + $parsedLogs[$parsedLogsLastKey]['stackTrace'][] = $trace_line;
154 + }
155 + break;
148 156 }
149 157 }
150 158 }
151 159