Skip to content

Commit fde1d22

Browse files
committed
Upd. Scan. Enhance scanner execution time management by implementing a maximum execution time check.
1 parent 3fcaf79 commit fde1d22

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/CleantalkSP/SpbctWP/Scanner/Surface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,17 @@ public function countFilesInDir($main_path)
499499
\RecursiveIteratorIterator::SELF_FIRST
500500
);
501501

502+
if (defined('SPBC_MAX_EXECUTION_TIME') && is_numeric(SPBC_MAX_EXECUTION_TIME)) {
503+
$max_execution_time = SPBC_MAX_EXECUTION_TIME;
504+
$start_time = time();
505+
}
506+
502507
foreach ($iterator as $fileInfo) {
508+
if (defined('SPBC_MAX_EXECUTION_TIME') && is_numeric(SPBC_MAX_EXECUTION_TIME)) {
509+
if ((time() - $start_time) > $max_execution_time) {
510+
break;
511+
}
512+
}
503513
try {
504514
if ($fileInfo->isLink()) {
505515
continue; // Skip symlinks

0 commit comments

Comments
 (0)