Skip to content

Fix backup download link — missing file= query parameter#970

Open
uAliAmer wants to merge 1 commit intoLinkStackOrg:mainfrom
uAliAmer:fix/backup-download-url
Open

Fix backup download link — missing file= query parameter#970
uAliAmer wants to merge 1 commit intoLinkStackOrg:mainfrom
uAliAmer:fix/backup-download-url

Conversation

@uAliAmer
Copy link

Bug

Backup files cannot be downloaded from the admin panel. Clicking a backup download button navigates the browser to the page URL instead of triggering a file download, and throws a JS error:

```
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
```

Root Cause

The download link is generated with the filename as a bare query key:

```php
// Generates: /admin/backups/?filename.zip
url('admin/backups') . '/?' . $entry
```

But the download handler checks `$_GET['file']`:

```php
if (isset($_GET['file'])) {
$filename = $_GET['file'];
// ... serve file
}
```

Since `$_GET['file']` is never set, the handler is skipped and the page renders as HTML, causing the JS error.

Fix

```php
// Generates: /admin/backups?file=filename.zip
url('admin/backups') . '?file=' . $entry
```

Two corrections in one:

  1. Removed the stray `/` before `?`
  2. Changed `$entry` to `file=$entry` to match what the handler expects

Test

Verified on a self-hosted instance behind an nginx reverse proxy — backup downloads work correctly after this change.

The download link was generated as /admin/backups/?filename.zip
but the download handler checks $_GET['file'], so the handler
was never triggered. The browser navigated to the page instead
of downloading the file, causing a JS error.

Changed: url('admin/backups') . '/?' . $entry
To:      url('admin/backups') . '?file=' . $entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant