Skip to content

Commit 7cc005c

Browse files
authored
Merge pull request #50992 from nextcloud/fix/fix-admin-audit-paths
fix(admin_audit): Fix incorrect truncation of files path in admin audit log
2 parents c1204c0 + 6118981 commit 7cc005c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

apps/admin_audit/lib/Actions/Files.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function read(BeforeNodeReadEvent $event): void {
3737
$node = $event->getNode();
3838
$params = [
3939
'id' => $node instanceof NonExistingFile ? null : $node->getId(),
40-
'path' => mb_substr($node->getInternalPath(), 5),
40+
'path' => $node->getPath(),
4141
];
4242
} catch (InvalidPathException|NotFoundException $e) {
4343
Server::get(LoggerInterface::class)->error(
@@ -76,8 +76,8 @@ public function afterRename(NodeRenamedEvent $event): void {
7676
$originalSource = $this->renamedNodes[$target->getId()];
7777
$params = [
7878
'newid' => $target->getId(),
79-
'oldpath' => mb_substr($originalSource->getInternalPath(), 5),
80-
'newpath' => mb_substr($target->getInternalPath(), 5),
79+
'oldpath' => $originalSource->getPath(),
80+
'newpath' => $target->getPath(),
8181
];
8282
} catch (InvalidPathException|NotFoundException $e) {
8383
Server::get(LoggerInterface::class)->error(
@@ -101,7 +101,7 @@ public function create(NodeCreatedEvent $event): void {
101101
try {
102102
$params = [
103103
'id' => $event->getNode()->getId(),
104-
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
104+
'path' => $event->getNode()->getPath(),
105105
];
106106
} catch (InvalidPathException|NotFoundException $e) {
107107
Server::get(LoggerInterface::class)->error(
@@ -127,8 +127,8 @@ public function copy(NodeCopiedEvent $event): void {
127127
$params = [
128128
'oldid' => $event->getSource()->getId(),
129129
'newid' => $event->getTarget()->getId(),
130-
'oldpath' => mb_substr($event->getSource()->getInternalPath(), 5),
131-
'newpath' => mb_substr($event->getTarget()->getInternalPath(), 5),
130+
'oldpath' => $event->getSource()->getPath(),
131+
'newpath' => $event->getTarget()->getPath(),
132132
];
133133
} catch (InvalidPathException|NotFoundException $e) {
134134
Server::get(LoggerInterface::class)->error(
@@ -151,7 +151,7 @@ public function write(NodeWrittenEvent $event): void {
151151
try {
152152
$params = [
153153
'id' => $node->getId(),
154-
'path' => mb_substr($node->getInternalPath(), 5),
154+
'path' => $node->getPath(),
155155
];
156156
} catch (InvalidPathException|NotFoundException $e) {
157157
Server::get(LoggerInterface::class)->error(
@@ -177,7 +177,7 @@ public function delete(BeforeNodeDeletedEvent $event): void {
177177
try {
178178
$params = [
179179
'id' => $event->getNode()->getId(),
180-
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
180+
'path' => $event->getNode()->getPath(),
181181
];
182182
} catch (InvalidPathException|NotFoundException $e) {
183183
Server::get(LoggerInterface::class)->error(

apps/admin_audit/lib/Listener/FileEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function beforePreviewFetched(BeforePreviewFetchedEvent $event): void {
4040
'height' => $event->getHeight(),
4141
'crop' => $event->isCrop(),
4242
'mode' => $event->getMode(),
43-
'path' => mb_substr($file->getInternalPath(), 5)
43+
'path' => $file->getPath(),
4444
];
4545
$this->log(
4646
'Preview accessed: (id: "%s", width: "%s", height: "%s" crop: "%s", mode: "%s", path: "%s")',

0 commit comments

Comments
 (0)