PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 All 135 releases
← All changes | inc/logger.php +6 -2 3.11.1 → trunk View file →
@@ -183,13 +183,14 @@
183 183 }
184 184
185 185 $buffer = min( $buffer * 2, 4096 );
186 186 }
187 -
187 + $pos = -1;
188 188 if ( ! empty( $separator ) && $separator_found ) {
189 189 $pos = strrpos( $output, $separator );
190 190 if ( $pos !== false ) {
191 191 $output = substr( $output, $pos + strlen( $separator ) );
192 + $pos = -1; // we reset the position to start from the beginning of the chunk when slicing.
192 193 }
193 194 }
194 195
195 196 // Extract the desired number of lines
@@ -196,9 +197,12 @@
196 197 $output_lines = explode( "\n", $output );
197 198 if ( empty( $separator ) || ! $separator_found ) {
198 199 $output = implode( "\n", array_slice( $output_lines, -$lines ) ); // fetch last n lines
199 200 } else {
200 - $output = implode( "\n", array_slice( $output_lines, 0, $lines ) ); // fetch from separator
201 + // Calculate the start position for slicing
202 + $start_pos = max( $pos + 1, count( $output_lines ) - $lines );
203 +
204 + $output = implode( "\n", array_slice( $output_lines, $start_pos, $lines ) ); // fetch from separator
201 205 }
202 206
203 207 fclose( $f );
204 208 return trim( $output );