Skip to content

Commit 0ac6903

Browse files
committed
Craft 4
1 parent 644e5e5 commit 0ac6903

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"name": "ether/logs",
33
"description": "Access logs from the CP",
4-
"version": "3.0.5",
54
"type": "craft-plugin",
65
"minimum-stability": "dev",
76
"require": {
8-
"craftcms/cms": "^3.0.0-RC1"
7+
"craftcms/cms": "^4.0.0"
98
},
109
"autoload": {
1110
"psr-4": {

src/Service.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ class Service extends Component
1111
public function truncate ($log)
1212
{
1313
$logsDir = Craft::getAlias('@storage/logs');
14-
file_put_contents($logsDir . DIRECTORY_SEPARATOR . $log, '');
15-
Craft::$app->getSession()->setNotice($log . ' truncated.');
14+
$success = file_put_contents($logsDir . DIRECTORY_SEPARATOR . $log, '');
15+
16+
if ($success !== false) Craft::$app->getSession()->setNotice($log . ' truncated.');
17+
else Craft::$app->getSession()->setError('Failed to truncate ' . $log . ', check file permissions');
1618
}
1719

1820
public function delete ($log)
1921
{
2022
$logsDir = Craft::getAlias('@storage/logs');
21-
unlink($logsDir . DIRECTORY_SEPARATOR . $log);
22-
Craft::$app->getSession()->setNotice($log . ' deleted.');
23+
$success = unlink($logsDir . DIRECTORY_SEPARATOR . $log);
24+
25+
if ($success !== false) Craft::$app->getSession()->setNotice($log . ' deleted.');
26+
else Craft::$app->getSession()->setError('Failed to delete ' . $log . ', check file permissions');
2327
}
2428

2529
}

src/Utility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function id (): string
2121
return 'logs';
2222
}
2323

24-
public static function iconPath ()
24+
public static function iconPath (): null|string
2525
{
2626
return Craft::getAlias('@ether/logs/utility_icon.svg');
2727
}

0 commit comments

Comments
 (0)