Commit 99bb40b8 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix: clear cache when deleting podcast banner

parent 209dfbd1
Pipeline #1234 passed with stages
in 7 minutes and 49 seconds
......@@ -65,6 +65,18 @@ class MediaModel extends Model
'updated_by',
];
/**
* clear cache before update if by any chance, the podcast name changes, so will the podcast link
*
* @var string[]
*/
protected $beforeUpdate = ['clearCache'];
/**
* @var string[]
*/
protected $beforeDelete = ['clearCache'];
/**
* Model constructor.
*
......@@ -166,4 +178,19 @@ class MediaModel extends Model
return $this->delete($media->id, true);
}
/**
* @param mixed[] $data
*
* @return mixed[]
*/
protected function clearCache(array $data): array
{
$mediaId = (is_array($data['id']) ? $data['id'][0] : $data['id']);
cache()
->delete("media#{$mediaId}");
return $data;
}
}
......@@ -381,6 +381,9 @@ class PodcastController extends BaseController
->withInput()
->with('errors', $mediaModel->errors());
}
(new PodcastModel())->clearCache([
'id' => $this->podcast->id,
]);
// remove banner url from actor
$actor = (new ActorModel())->getActorById($this->podcast->actor_id);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment