Skip to content

Commit 13cc0f0

Browse files
committed
Fix crash when archive folder setting is cleared to null
The Setting model's getValueAttribute accessor requires a string, but clearing the field in the admin UI saves null. Replaced (array) cast of Settings (which triggers all accessors at once) with individual property access wrapped in try/catch for the archive_folder setting. Bump version to 2.2.3.
1 parent 865cd06 commit 13cc0f0

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ The Abuse package retrieves abuse reports via IMAP from an email account and dis
99

1010
## Changelog
1111

12+
### v2.2.3
13+
- Fix crash when archive folder setting is cleared (null value triggers Setting accessor TypeError)
14+
1215
### v2.2.2
1316
- Add archive folder setting label and auto-detect description to admin UI
1417

app/Email/EmailFetcher.php

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,29 @@ private function connect() {
5555
return $this->connection;
5656
}
5757

58-
$settings = (array) app('Settings');
58+
$s = app('Settings');
59+
60+
$host = (string) ($s->{'pkg.abuse.auth.host'} ?? '');
61+
$user = (string) ($s->{'pkg.abuse.auth.user'} ?? '');
62+
$pass = (string) ($s->{'pkg.abuse.auth.pass'} ?? '');
5963

6064
// if any of the settings are empty then the Fetcher should do nothing.
61-
if (
62-
empty($settings['pkg.abuse.auth.host']) ||
63-
empty($settings['pkg.abuse.auth.user']) ||
64-
empty($settings['pkg.abuse.auth.pass'])
65-
) {
65+
if (empty($host) || empty($user) || empty($pass)) {
6666
return;
6767
}
6868

69-
$server = new Server(
70-
$settings['pkg.abuse.auth.host'],
71-
'993',
72-
'/imap/ssl/novalidate-cert'
73-
);
74-
75-
$this->connection = $server->authenticate(
76-
$settings['pkg.abuse.auth.user'],
77-
$settings['pkg.abuse.auth.pass']
78-
);
79-
80-
$this->archiveFolder = $this->resolveArchiveFolder(
81-
$settings['pkg.abuse.auth.archive_folder'] ?? '',
82-
$settings['pkg.abuse.auth.host'] ?? ''
83-
);
69+
$server = new Server($host, '993', '/imap/ssl/novalidate-cert');
70+
71+
$this->connection = $server->authenticate($user, $pass);
72+
73+
$archiveSetting = '';
74+
try {
75+
$archiveSetting = (string) ($s->{'pkg.abuse.auth.archive_folder'} ?? '');
76+
} catch (\Throwable $exc) {
77+
// Setting value is null — treat as empty for auto-detection.
78+
}
79+
80+
$this->archiveFolder = $this->resolveArchiveFolder($archiveSetting, $host);
8481

8582
return $this->connection;
8683
}

scp-package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"slug": "abuse",
44
"name": "Abuse Reports",
55
"description": "The Abuse package retrieves abuse reports via IMAP from an email account and distributes the reports to the appropriate server tenants based on server IP. It adds a frontend to SynergyCP that allows Clients and Administrators to see and comment on reports.",
6-
"semver": "2.2.2",
6+
"semver": "2.2.3",
77
"download_url": "https://distribution.synergycp.com/packages/synergycp/abuse/download.tar.gz",
88
"release_date_unix": 1774699200,
99
"changelog": [
10-
"Add archive folder setting label and description to admin UI"
10+
"Fix crash when archive folder setting is cleared to null"
1111
]
1212
}
1313
}

0 commit comments

Comments
 (0)