Skip to content

Commit 588d5f8

Browse files
committed
fix: initialize variables to prevent warnings on early exit
1 parent a99864b commit 588d5f8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/index.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,16 @@ function hashing_allowed_for_file(string $path): bool
327327

328328
// get real path and check if accessible (open_basedir)
329329
$local_path = realpath(PUBLIC_FOLDER . $request_uri);
330+
331+
// Initialize variables to avoid warnings in case of early exit (404)
332+
$path_is_dir = false;
333+
$max_pages = 1;
334+
$page_start_offset = 0;
335+
$total_items = 0;
336+
$total_size = 0;
337+
$pages = [];
338+
$current_page = 1;
339+
330340
if (!str_starts_with($local_path, PUBLIC_FOLDER)) {
331341
goto skip; /* File should be ignored so skip to 404 */
332342
}
@@ -355,9 +365,6 @@ public function __toString(): string
355365
/* @var array<File> */
356366
$sorted = [];
357367

358-
$total_items = 0;
359-
$total_size = 0;
360-
361368
/**
362369
* Check if file/folder should be hidden (ignored)
363370
* @param string $path full path to file or folder
@@ -663,10 +670,6 @@ function downloadBatch(array $urls) {
663670
}
664671
$[end]$
665672
666-
$max_pages = 1;
667-
$page_start_offset = 0;
668-
$pages = [];
669-
670673
// local path exists
671674
if ($path_is_dir) {
672675
$[if `process.env.DOWNLOAD_COUNTER === "true"`]$

0 commit comments

Comments
 (0)