Ticket #296 (closed bug: invalid)
Wrong implementation of "Song.get_rel_path()" is broken
| Reported by: | manski | Owned by: | vollmerk |
|---|---|---|---|
| Priority: | major | Milestone: | 3.4.x Stable Release |
| Component: | Streaming / Playback | Version: | 3.4.x |
| Keywords: | Cc: |
Description
The implementation of Song.get_rel_path() is broken (in r1640). It's using a private method (Catalog._get_info()) that leads to an error. It also tries to access the elements of the array info (returned by _get_info()) by using the object operator (->) which doesn't work (i.e. empty strings are returned).
A possible fix to may be the following code snippet:
/**
* @function get_rel_path
* @discussion returns the path of the song file stripped of the catalog path
* used for mpd playback
*/
function get_rel_path($file_path=null,$catalog_id=null) {
if (!isset($file_path)) {
$file_path = $this->file;
}
if (!isset($catalog_id)) {
$catalog_id = $this->catalog;
}
$catalog = new Catalog( $catalog_id );
$catalog_path = rtrim($catalog->path, "/");
return( str_replace( $catalog_path . "/", "", $file_path ) );
} // get_rel_path
This implementation works different to the old one in the following aspects:
- If file_path is set but catalog_id isn't the song's catalog id is now assigned to catalog_id. (This didn't work previously.)
- The song's information are directly retrieved from the class' fields rather than executing a database query (via _get_info()). I don't know if this is what you intended but as far I can tell this should work.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
