summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Vollmer <vollmer@ampache.org>2010-12-09 22:08:59 -0400
committerKarl Vollmer <vollmer@ampache.org>2010-12-09 22:08:59 -0400
commit5cd7146c4d3c011e40b42d0b4c6fcf8c90eeb09d (patch)
treefd973954698d5bc5c7401165a8658f62b88badbe
parent36294e3529eada2de8ed51c5b135ab5376e16700 (diff)
downloadampache-5cd7146c4d3c011e40b42d0b4c6fcf8c90eeb09d.tar.gz
ampache-5cd7146c4d3c011e40b42d0b4c6fcf8c90eeb09d.tar.bz2
ampache-5cd7146c4d3c011e40b42d0b4c6fcf8c90eeb09d.zip
Resolve #90 and #89, remove democratic playlist entries if there is a fatal error when trying to play them
-rw-r--r--lib/class/democratic.class.php14
-rw-r--r--play/index.php21
2 files changed, 21 insertions, 14 deletions
diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php
index 9a646859..c499d714 100644
--- a/lib/class/democratic.class.php
+++ b/lib/class/democratic.class.php
@@ -493,6 +493,20 @@ class Democratic extends tmpPlaylist {
} // delete_votes
/**
+ * delete_from_oid
+ * This takes an OID and type and removes the object from the democratic playlist
+ */
+ public function delete_from_oid($oid,$object_type) {
+
+ $row_id = $democratic ->get_uid_from_object_id($oid,$object_type);
+ if ($row_id) { $democratic->delete_votes($row_id); }
+ else { debug_event('Democratic','Unable to find Votes for ' . $oid . ' of type ' . $object_type,'3'); }
+
+ return true;
+
+ } // delete_from_oid
+
+ /**
* delete
* This deletes a democratic playlist
*/
diff --git a/play/index.php b/play/index.php
index eb1b2d5a..0639bc79 100644
--- a/play/index.php
+++ b/play/index.php
@@ -171,6 +171,8 @@ $catalog = new Catalog($media->catalog);
/* If the song is disabled */
if (!make_bool($media->enabled)) {
debug_event('Play',"Error: $media->file is currently disabled, song skipped",'5');
+ // Check to see if this is a democratic playlist, if so remove it completely
+ if ($demo_id) { $democratic->delete_from_oid($oid,'song'); }
exit;
}
@@ -201,13 +203,7 @@ if ($catalog->catalog_type == 'remote') {
debug_event('xmlrpc-stream',"Start XML-RPC Stream - " . $media->file . $extra_info,'5');
/* If this is a voting tmp playlist remove the entry, we do this regardless of play amount */
- if ($demo_id) {
- $row_id = $democratic->get_uid_from_object_id($oid,'song');
- if ($row_id) {
- debug_event('Democratic','Removing ' . $media->title . ' from Democratic Playlist','1');
- $democratic->delete_votes($row_id);
- }
- } // if tmp_playlist
+ if ($demo_id) { $democratic->delete_from_oid($oid,'song'); } // if democratic
exit;
} // end if remote catalog
@@ -223,6 +219,8 @@ if (!$media->file OR !is_readable($media->file)) {
debug_event('Play',"Error song $media->file ($media->title) does not have a valid filename specified",'2');
echo "Error: Invalid Song Specified, file not found or file unreadable";
+ // Remove the song votes if this is a democratic song
+ if ($demo_id) { $democratic->delete_from_oid($oid,'song'); }
exit;
}
@@ -318,6 +316,7 @@ else {
if (!is_resource($fp)) {
debug_event('Play',"Error: Unable to open $media->file for reading",'2');
+ if ($demo_id) { $democratic->delete_from_oid($oid,'song'); }
cleanup_and_exit($lastid);
}
} // else not downsampling
@@ -392,13 +391,7 @@ else {
/* If this is a voting tmp playlist remove the entry, we do this regardless of play amount */
-if ($demo_id) {
- $row_id = $democratic->get_uid_from_object_id($oid,'song');
- if ($row_id) {
- debug_event('Democratic','Removing ' . $media->title . ' from Democratic Playlist','1');
- $democratic->delete_votes($row_id);
- }
-} // if tmp_playlist
+if ($demo_id) { $democratic->delete_from_oid($oid,'song'); }
/* Clean up any open ends */
if (Config::get('play_type') == 'downsample' || !$media->native_stream()) {