Skip to content

Commit

Permalink
Fix issue in getType function that will raise an "undefined index" …
Browse files Browse the repository at this point in the history
…notice when there's no file.

Fix bug in PodcastPage (missing $this->).
  • Loading branch information
bummzack committed Oct 8, 2015
1 parent 02fb158 commit 05ceb72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions code/dataobjects/PodcastEpisode.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ public function getMime() {
* @return string
*/
public function getType() {
$filename = $this->EpisodeFile()->getFilename();
$filename = explode('.', $filename);
// return an empty string if there's no file
if(!$this->EpisodeFileID){
return '';
}

$mime_types = array(
'mp3' => 'audio'
Expand All @@ -145,7 +147,7 @@ public function getType() {
,'3gp' => 'video'
);

$extension = strtolower(end($filename));
$extension = strtolower($this->EpisodeFile()->getExtension());

return $mime_types[$extension];
}
Expand Down
2 changes: 1 addition & 1 deletion code/pagetypes/PodcastPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function podcastEpisodes() {
*/
public function paginatedPodcastEpisodes() {
$paginatedList = new PaginatedList(
podcastEpisodes()
$this->podcastEpisodes()
->filter(array('BlockEpisode' => '0'))
->sort('EpisodeDate', 'DESC')
, $this->request
Expand Down

0 comments on commit 05ceb72

Please sign in to comment.