Skip to content

Commit

Permalink
Fix ability to edit empty files (#15977)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-H committed Jan 19, 2022
1 parent a22cf31 commit 76c39e8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/Revolution/Sources/modMediaSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,11 @@ public function getMetaData($path)
public function getObjectContents($path)
{
try {
if (!$file = $this->filesystem->read($path)) {
if (!$this->filesystem->fileExists($path)) {
$this->addError('file', $this->xpdo->lexicon('file_err_nf'));
return [];
}
$content = $this->filesystem->read($path);
} catch (FilesystemException | UnableToReadFile $e) {
$this->xpdo->log(modX::LOG_LEVEL_ERROR, $e->getMessage());
return [];
Expand All @@ -596,7 +597,7 @@ public function getObjectContents($path)
'size' => $this->filesystem->fileSize($path),
'last_accessed' => $this->filesystem->lastModified($path), // We only have lastModified() here.
'last_modified' => $this->filesystem->lastModified($path),
'content' => $file,
'content' => $content,
'mime' => $this->filesystem->mimeType($path),
'image' => $this->isFileImage($path, $imageExtensions),
];
Expand Down

0 comments on commit 76c39e8

Please sign in to comment.