Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.5' into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
fashxp committed Jan 12, 2023
2 parents fbc5060 + a3ab97d commit ad03a42
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
34 changes: 21 additions & 13 deletions bundles/AdminBundle/Controller/Admin/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,8 @@ public function showFileObjectAction(Request $request)
$storage = Storage::get('application_log');

if ($storage->fileExists($filePath)) {
$fileData = $storage->readStream($filePath);
$response = new StreamedResponse(
static function () use ($fileData) {
echo stream_get_contents($fileData);
}
);
$fileHandle = $storage->readStream($filePath);
$response = $this->getResponseForFileHandle($fileHandle);
$response->headers->set('Content-Type', 'text/plain');
} else {
// Fallback to local path when file is not found in flysystem that might still be using the constant
Expand All @@ -254,13 +250,8 @@ static function () use ($fileData) {
}

if (file_exists($filePath)) {
$response = new StreamedResponse(
static function () use ($filePath) {
$handle = fopen($filePath, 'rb');
fpassthru($handle);
fclose($handle);
}
);
$fileHandle = fopen($filePath, 'rb');
$response = $this->getResponseForFileHandle($fileHandle);
$response->headers->set('Content-Type', 'text/plain');
} else {
$response = new Response();
Expand All @@ -272,4 +263,21 @@ static function () use ($filePath) {

return $response;
}

/**
* @param resource $fileHandle
*
* @return StreamedResponse
*/
private function getResponseForFileHandle($fileHandle)
{
return new StreamedResponse(
static function () use ($fileHandle) {
while (!feof($fileHandle)) {
echo fread($fileHandle, 8192);
}
fclose($fileHandle);
}
);
}
}
4 changes: 2 additions & 2 deletions models/DataObject/ClassDefinition/Data/UrlSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ public function save($object, $params = [])
}

// if now exception is thrown then the slug is owned by a diffrent object/field
throw new \Exception('Unique constraint violated. Slug alreay used by object '
. $existingSlug->getFieldname() . ', fieldname: ' . $existingSlug->getFieldname());
throw new \Exception('Unique constraint violated. Slug "' . $slug['slug'] . '" is already used by object '
. $existingSlug->getObjectId() . ', fieldname: ' . $existingSlug->getFieldname());
}
}

Expand Down

0 comments on commit ad03a42

Please sign in to comment.