Skip to content

Commit 2545381

Browse files
Copilotswissspidy
andcommitted
Remove unnecessary file size check as get_file_data() reads only 8KB
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 97a5b26 commit 2545381

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

src/Checksum_Plugin_Command.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
*/
1313
class Checksum_Plugin_Command extends Checksum_Base_Command {
1414

15-
/**
16-
* Maximum file size (in bytes) to read when detecting plugin version.
17-
* Set to 1MB to prevent memory exhaustion attacks.
18-
*/
19-
const MAX_FILE_SIZE_FOR_VERSION_DETECTION = 1048576;
20-
2115
/**
2216
* Cached plugin data for all installed plugins.
2317
*
@@ -262,9 +256,7 @@ private function detect_version_from_directory( $plugin_dir ) {
262256
$files = glob( $plugin_path . '/*.php' );
263257
if ( is_array( $files ) && ! empty( $files ) ) {
264258
foreach ( $files as $file ) {
265-
// Check file size to prevent memory exhaustion
266-
$file_size = filesize( $file );
267-
if ( false !== $file_size && $file_size < self::MAX_FILE_SIZE_FOR_VERSION_DETECTION && is_readable( $file ) ) {
259+
if ( is_readable( $file ) ) {
268260
$file_data = get_file_data(
269261
$file,
270262
array( 'Version' => 'Version' )

0 commit comments

Comments
 (0)