Skip to content

Commit 82a4ce3

Browse files
Merge branch '5.4' into 6.0
* 5.4: [DependencyInjection] Add `SubscribedService` attribute, deprecate current `ServiceSubscriberTrait` usage Use try/finally to restore error handlers Allow serializer default context configuration
2 parents 00b52ff + 2f128ab commit 82a4ce3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

File/File.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ public function move(string $directory, string $name = null): self
8787
$target = $this->getTargetFile($directory, $name);
8888

8989
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
90-
$renamed = rename($this->getPathname(), $target);
91-
restore_error_handler();
90+
try {
91+
$renamed = rename($this->getPathname(), $target);
92+
} finally {
93+
restore_error_handler();
94+
}
9295
if (!$renamed) {
9396
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
9497
}

File/UploadedFile.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ public function move(string $directory, string $name = null): File
168168
$target = $this->getTargetFile($directory, $name);
169169

170170
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
171-
$moved = move_uploaded_file($this->getPathname(), $target);
172-
restore_error_handler();
171+
try {
172+
$moved = move_uploaded_file($this->getPathname(), $target);
173+
} finally {
174+
restore_error_handler();
175+
}
173176
if (!$moved) {
174177
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
175178
}

0 commit comments

Comments
 (0)