Skip to content

Commit 90a941d

Browse files
committed
Add control on zip file addition
1 parent 635db99 commit 90a941d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

bea-logger.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,15 @@ private function maybe_zip_rotated_file( $rotated_path ) {
194194
return;
195195
}
196196

197-
$zip->addFile( $rotated_path, basename( $rotated_path ) );
197+
$entry_name = basename( $rotated_path );
198+
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- ZipArchive API property.
199+
if ( ! $zip->addFile( $rotated_path, $entry_name ) || $zip->numFiles < 1 ) {
200+
$zip->close();
201+
if ( is_file( $zip_path ) ) {
202+
unlink( $zip_path );
203+
}
204+
return;
205+
}
198206

199207
if ( ! $zip->close() ) {
200208
if ( is_file( $zip_path ) ) {

0 commit comments

Comments
 (0)