You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Refactored the fetchAndUnzipModule method in class.action.quickPick.php to improve logging and progress handling, now reporting progress as a percentage.
Enhanced the unzipFile method in class.core.php for more accurate progress reporting, including handling for 100% completion.
Updated quickpick.js to improve progress bar handling and removed unnecessary aria-valuenow attribute setting.
Added copyright information to quickpick.js.
Changes walkthrough 📝
Relevant files
Enhancement
class.action.quickPick.php
Refactor fetchAndUnzipModule for better progress handling
core/classes/actions/class.action.quickPick.php
Refactored fetchAndUnzipModule method for improved logging and progress handling.
Changed progress reporting to use percentage instead of file count.
Improved error handling for unsupported file extensions.
Code Duplication The code for flushing output buffer is repeated multiple times. Consider extracting this into a separate function to reduce duplication.
Performance Concern The unzipFile method reads the process output in small chunks and processes each line individually, which could be inefficient for large files. Consider buffering larger chunks of output before processing.
Potential Bug The 'isCompleted' flag is checked after the loop, but it's not clear where it's set. This could lead to unexpected behavior if the flag is not properly managed.
+$startTime = time();+$timeout = 300; // 5 minutes timeout
while ( !feof( $process ) ) {
+ if (time() - $startTime > $timeout) {+ Util::logError("Extraction process timed out after $timeout seconds");+ break;+ }
$buffer .= fread( $process, 8192 ); // Read in chunks of 8KB
while ( ($pos = strpos( $buffer, "\r" )) !== false ) {
$line = substr( $buffer, 0, $pos );
$buffer = substr( $buffer, $pos + 1 );
$line = trim( $line ); // Remove any leading/trailing whitespace
Util::logTrace( "Processing line: $line" );
Apply this suggestion
Suggestion importance[1-10]: 9
Why: Adding a timeout mechanism is a significant enhancement that prevents potential infinite loops, improving the robustness and reliability of the code.
9
Improve error logging for unsupported file extensions
Consider adding error logging for the case when the file extension is not supported. This will help with debugging and provide more context for the error.
Why: Enhancing error logging provides better debugging information, which is important for diagnosing issues related to unsupported file extensions.
8
Best practice
Use a more descriptive variable name for clarity
Consider using a more descriptive variable name instead of $result. For example, $fileRetrievalResult would better convey the purpose of this variable.
Why: The suggestion to use a more descriptive variable name improves code readability and maintainability, but it is not crucial for functionality.
6
Use a constant for the file reading chunk size
Consider using a constant for the chunk size (8192) in the file reading loop. This would make the code more maintainable and allow for easy adjustments if needed.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
enhancement, bug_fix
Description
fetchAndUnzipModule
method inclass.action.quickPick.php
to improve logging and progress handling, now reporting progress as a percentage.unzipFile
method inclass.core.php
for more accurate progress reporting, including handling for 100% completion.quickpick.js
to improve progress bar handling and removed unnecessaryaria-valuenow
attribute setting.quickpick.js
.Changes walkthrough 📝
class.action.quickPick.php
Refactor fetchAndUnzipModule for better progress handling
core/classes/actions/class.action.quickPick.php
fetchAndUnzipModule
method for improved logging andprogress handling.
class.core.php
Improve unzipFile method for accurate progress reporting
core/classes/class.core.php
unzipFile
method to improve progress reporting.quickpick.js
Update progress bar handling and add copyright
core/resources/homepage/js/quickpick.js
aria-valuenow
attribute.