Skip to content

Commit

Permalink
Fixed "Undefined array key" warnings
Browse files Browse the repository at this point in the history
(cherry picked from commit ce590d6)
  • Loading branch information
jonasraoni committed Apr 2, 2024
1 parent 40984cd commit 37d76a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions classes/announcement/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function edit(Announcement $announcement, array $params)
$this->dao->update($newAnnouncement);

$image = $newAnnouncement->getImage();
$hasNewImage = $image && $image['temporaryFileId'];
$hasNewImage = $image['temporaryFileId'] ?? null;

if ((!$image || $hasNewImage) && $announcement->getImage()) {
$this->deleteImage($announcement);
Expand Down Expand Up @@ -227,7 +227,7 @@ public function getFileUploadBaseUrl(?Context $context = null): string
protected function handleImageUpload(Announcement $announcement): void
{
$image = $announcement->getImage();
if ($image && $image['temporaryFileId']) {
if ($image['temporaryFileId'] ?? null) {
$user = Application::get()->getRequest()->getUser();
$image = $announcement->getImage();
$temporaryFileManager = new TemporaryFileManager();
Expand Down Expand Up @@ -315,7 +315,7 @@ protected function getImageFilename(Announcement $announcement, TemporaryFile $t
protected function deleteImage(Announcement $announcement): void
{
$image = $announcement->getImage();
if ($image && $image['uploadName']) {
if ($image['uploadName'] ?? null) {
$publicFileManager = new PublicFileManager();
$filesPath = $announcement->getAssocId()
? $publicFileManager->getContextFilesPath($announcement->getAssocId())
Expand Down
6 changes: 3 additions & 3 deletions classes/highlight/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function edit(Highlight $highlight, array $params): void
$this->dao->update($newHighlight);

$image = $newHighlight->getImage();
$hasNewImage = $image && $image['temporaryFileId'];
$hasNewImage = $image['temporaryFileId'] ?? null;

if ((!$image || $hasNewImage) && $highlight->getImage()) {
$this->deleteImage($highlight);
Expand Down Expand Up @@ -263,7 +263,7 @@ public function getFileUploadBaseUrl(?Context $context = null): string
protected function handleImageUpload(Highlight $highlight): void
{
$image = $highlight->getImage();
if ($image && $image['temporaryFileId']) {
if ($image['temporaryFileId'] ?? null) {
$user = Application::get()->getRequest()->getUser();
$image = $highlight->getImage();
$temporaryFileManager = new TemporaryFileManager();
Expand Down Expand Up @@ -347,7 +347,7 @@ protected function getImageFilename(Highlight $highlight, TemporaryFile $tempora
protected function deleteImage(Highlight $highlight): void
{
$image = $highlight->getImage();
if ($image && $image['uploadName']) {
if ($image['uploadName'] ?? null) {
$publicFileManager = new PublicFileManager();
$filesPath = $highlight->getContextId()
? $publicFileManager->getContextFilesPath($highlight->getContextId())
Expand Down

0 comments on commit 37d76a6

Please sign in to comment.