From 698d2e7a1f80f38172f70886a3b3128fbca3c8f3 Mon Sep 17 00:00:00 2001 From: Netkas Date: Wed, 18 Oct 2023 16:03:40 -0400 Subject: [PATCH] Updated file tracking in Runtime class Implemented changes in Runtime.php to better handle file tracking and to prevent unnecessary inclusion of duplicate files during Runtime. Instead of directly checking if a file is already included, we now create a unique identifier for each file using a crc32 hash function. This identifier (instead of the file path) is checked and stored in the inclusion list, allowing for better handling of dynamic or virtual files. --- CHANGELOG.md | 1 + src/ncc/Classes/Runtime.php | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69534a..75092a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This update introduces minor bug fixes. ### Fixed - Improve build efficiency by preventing duplicate merges + - Updated file tracking in Runtime class ## [2.0.3] - 2023-10-17 diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index 7800e67..fb43d82 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -572,9 +572,16 @@ return; } - if(!in_array($path, self::$included_files, true)) + $acquired_name = $path; + + if(!is_file($path)) { - self::$included_files[] = $path; + $acquired_name = hash('crc32', $acquired_file); + } + + if(!in_array($acquired_name, self::$included_files, true)) + { + self::$included_files[] = sprintf('virtual(%s)', $acquired_name); } self::extendedEvaluate($acquired_file); @@ -617,9 +624,16 @@ throw new RuntimeException(sprintf('Failed to acquire file "%s" at runtime: %s', $path, $e->getMessage()), $e->getCode(), $e); } - if(!in_array($path, self::$included_files, true)) + $acquired_name = $path; + + if(!is_file($path)) { - self::$included_files[] = $path; + $acquired_name = hash('crc32', $acquired_file); + } + + if(!in_array($acquired_name, self::$included_files, true)) + { + self::$included_files[] = sprintf('virtual(%s)', $acquired_name); } self::extendedEvaluate($acquired_file);