File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments