mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-06 18:31:05 +00:00
fix(platforms): trim platform url before validation and storage
--> Having a URL with spaces in the beginning or end would cause the platform to be deleted
This commit is contained in:
parent
c94bd7cf81
commit
259fe5f697
@ -145,6 +145,8 @@ class PlatformModel extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed[] $podcastsPlatformsData
|
* @param mixed[] $podcastsPlatformsData
|
||||||
|
*
|
||||||
|
* @return int|false Number of rows inserted or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function savePodcastPlatforms(
|
public function savePodcastPlatforms(
|
||||||
int $podcastId,
|
int $podcastId,
|
||||||
@ -165,6 +167,11 @@ class PlatformModel extends Model
|
|||||||
|
|
||||||
$this->db->query($deleteJoinQuery, [$podcastId, $platformType]);
|
$this->db->query($deleteJoinQuery, [$podcastId, $platformType]);
|
||||||
|
|
||||||
|
if ($podcastsPlatformsData === []) {
|
||||||
|
// no rows inserted
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->db
|
return $this->db
|
||||||
->table('podcasts_platforms')
|
->table('podcasts_platforms')
|
||||||
->insertBatch($podcastsPlatformsData);
|
->insertBatch($podcastsPlatformsData);
|
||||||
|
@ -70,7 +70,7 @@ class PodcastPlatformController extends BaseController
|
|||||||
$this->request->getPost('platforms')
|
$this->request->getPost('platforms')
|
||||||
as $platformSlug => $podcastPlatform
|
as $platformSlug => $podcastPlatform
|
||||||
) {
|
) {
|
||||||
$podcastPlatformUrl = $podcastPlatform['url'];
|
$podcastPlatformUrl = trim((string) $podcastPlatform['url']);
|
||||||
if ($podcastPlatformUrl === null) {
|
if ($podcastPlatformUrl === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -79,11 +79,12 @@ class PodcastPlatformController extends BaseController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$podcastPlatformAccountId = trim((string) $podcastPlatform['account_id']);
|
||||||
$podcastsPlatformsData[] = [
|
$podcastsPlatformsData[] = [
|
||||||
'platform_slug' => $platformSlug,
|
'platform_slug' => $platformSlug,
|
||||||
'podcast_id' => $this->podcast->id,
|
'podcast_id' => $this->podcast->id,
|
||||||
'link_url' => $podcastPlatformUrl,
|
'link_url' => $podcastPlatformUrl,
|
||||||
'account_id' => $podcastPlatform['account_id'] === '' ? null : $podcastPlatform['account_id'],
|
'account_id' => $podcastPlatformAccountId === '' ? null : $podcastPlatformAccountId,
|
||||||
'is_visible' =>
|
'is_visible' =>
|
||||||
array_key_exists('visible', $podcastPlatform) &&
|
array_key_exists('visible', $podcastPlatform) &&
|
||||||
$podcastPlatform['visible'] === 'yes',
|
$podcastPlatform['visible'] === 'yes',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user