Skip to content

Commit

Permalink
Fix a big bunch of undefined variable access warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mherger committed Nov 22, 2016
1 parent a50f585 commit ff23c8d
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 44 deletions.
1 change: 1 addition & 0 deletions Slim/Buttons/XMLBrowser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ sub gotOPML {
# keep track of station icons
if (
( $item->{play} || $item->{playlist} || ($item->{type} && ($item->{type} eq 'audio' || $item->{type} eq 'playlist')) )
&& $item->{url} && !ref $item->{url}
&& $item->{url} =~ /^http/
&& $item->{url} !~ m|\.com/api/\w+/v1/opml|
&& ( my $cover = $item->{image} || $item->{cover} )
Expand Down
4 changes: 2 additions & 2 deletions Slim/Control/Commands.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1054,9 +1054,9 @@ sub playlistJumpCommand {

# if we're jumping +1/-1 in the index let squeezeplay know this showBriefly is to be styled accordingly
my $jiveIconStyle = undef;
if ($index eq '-1') {
if ($index && $index eq '-1') {
$jiveIconStyle = 'rew';
} elsif ($index eq '+1') {
} elsif ($index && $index eq '+1') {
$jiveIconStyle = 'fwd';
}
$showStatus->($jiveIconStyle);
Expand Down
2 changes: 1 addition & 1 deletion Slim/Control/Stdio.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ sub processRequest {

main::INFOLOG && $log->info("Got line: $firstline");

my $message = executeCmd($firstline);
my $message = executeCmd($firstline) || '';

main::INFOLOG && $log->info("Response is: $message");

Expand Down
1 change: 1 addition & 0 deletions Slim/Control/XMLBrowser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ sub _cliQuery_done {
# keep track of station icons
if (
$isPlayable
&& $item->{url} && !ref $item->{url}
&& $item->{url} =~ /^http/
&& $item->{url} !~ m|\.com/api/\w+/v1/opml|
&& (my $cover = ($item->{image} || $item->{cover}))
Expand Down
2 changes: 1 addition & 1 deletion Slim/Formats/XML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sub _cacheKey {
my $cachekey = $url;

if ($client) {
$cachekey .= '-' . $client->languageOverride;
$cachekey .= '-' . ($client->languageOverride || '');
}

return $cachekey . '_parsedXML';
Expand Down
2 changes: 1 addition & 1 deletion Slim/Menu/AlbumInfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ sub cliQuery {
my $menuMode = $request->getParam('menu') || 0;
my $menuContext = $request->getParam('context') || 'normal';
my $playlist_index = defined( $request->getParam('playlist_index') ) ? $request->getParam('playlist_index') : undef;
my $connectionId = $request->connectionID;
my $connectionId = $request->connectionID || '';

my %filter;
foreach (qw(artist_id genre_id year library_id)) {
Expand Down
2 changes: 1 addition & 1 deletion Slim/Menu/ArtistInfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ sub cliQuery {
my $menuMode = $request->getParam('menu') || 0;
my $menuContext = $request->getParam('context') || 'normal';
my $playlist_index = defined( $request->getParam('playlist_index') ) ? $request->getParam('playlist_index') : undef;
my $connectionId = $request->connectionID;
my $connectionId = $request->connectionID || '';

my $tags = {
menuMode => $menuMode,
Expand Down
2 changes: 1 addition & 1 deletion Slim/Menu/BrowseLibrary.pm
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ sub _generic {
# remote_library might be part of the @searchTags. But it's to be consumed by
# BrowseLibrary, rather than by the CLI.
if (!$args->{remote_library}) {
($args->{remote_library}) = map { /remote_library:(.*)/ && $1 } grep /remote_library/, @$queryTags;
($args->{remote_library}) = map { /remote_library:(.*)/ && $1 } grep { $_ && /remote_library/ } @$queryTags;
}

# library_id:-1 is supposed to clear/override the global library_id
Expand Down
2 changes: 1 addition & 1 deletion Slim/Menu/FolderInfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ sub cliQuery {
my $client = $request->client;
my $folder_id = $request->getParam('folder_id');
my $menuMode = $request->getParam('menu') || 0;
my $connectionId = $request->connectionID;
my $connectionId = $request->connectionID || '';

unless ( $folder_id || $cachedFeed{$connectionId} ) {
$request->setStatusBadParams();
Expand Down
2 changes: 1 addition & 1 deletion Slim/Networking/SimpleAsyncHTTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ sub _cacheKey {
my $cachekey = $url;

if ($client) {
$cachekey .= '-' . $client->languageOverride;
$cachekey .= '-' . ($client->languageOverride || '');
}

return $cachekey;
Expand Down
3 changes: 2 additions & 1 deletion Slim/Player/Protocols/Volatile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use strict;

use Slim::Music::Artwork;
use Slim::Utils::Log;
use Slim::Utils::Strings qw(cstring);
use base qw(Slim::Player::Protocols::File);

sub isRemote { 1 }
Expand All @@ -35,7 +36,7 @@ sub getMetadataFor {
my $attributes = Slim::Formats->readTags( $path );

# make sure we have a value for artist, or we'll end up scanning the file over and over again
$attributes->{ARTIST} = $client->string('NO_ARTIST') unless defined $attributes->{ARTIST};
$attributes->{ARTIST} = cstring($client, 'NO_ARTIST') unless defined $attributes->{ARTIST};

$track->setAttributes($attributes) if $attributes && keys %$attributes;

Expand Down
2 changes: 1 addition & 1 deletion Slim/Plugin/Deezer/ProtocolHandler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ sub getMetadataFor {
my $song = $client->currentSongForUrl($url);
if (!$song || !($url = $song->pluginData('radioTrackURL'))) {
return {
title => $url =~ /flow\.dzr/ ? $client->string('PLUGIN_DEEZER_FLOW') : $client->string('PLUGIN_DEEZER_SMART_RADIO'),
title => ($url && $url =~ /flow\.dzr/) ? $client->string('PLUGIN_DEEZER_FLOW') : $client->string('PLUGIN_DEEZER_SMART_RADIO'),
bitrate => '320k CBR',
type => 'MP3 (Deezer)',
icon => $icon,
Expand Down
2 changes: 1 addition & 1 deletion Slim/Plugin/ExtendedBrowseModes/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ sub _hitlist { if (main::STATISTICS) {
Slim::Menu::BrowseLibrary::_tracks( $client, sub {
my ($result) = @_;

my $isWeb = $args->{isControl} && !$client->controlledBy;
my $isWeb = $args->{isControl} && !($client && $client->controlledBy);

$result->{items} = [
map {
Expand Down
2 changes: 1 addition & 1 deletion Slim/Plugin/WiMP/ProtocolHandler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sub bufferThreshold {
$url = $client->playingSong()->track()->url() unless $url =~ /\.(?:fla?c|mp3)$/;

my ($trackId, $format) = _getStreamParams( $url );
return ($format eq 'flac' ? 96 : 32) * ($prefs->get('bufferSecs') || 3);
return ($format eq 'flac' ? 80 : 32) * ($prefs->get('bufferSecs') || 3);
}

sub canSeek { 1 }
Expand Down
4 changes: 4 additions & 0 deletions Slim/Utils/ArtworkCache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ sub set {

my $ref = $data->{data_ref};

$data->{content_type} ||= '';
$data->{mtime} ||= 0;
$data->{original_path} ||= '';

my $packed = pack( 'A3LS', $data->{content_type}, $data->{mtime}, length( $data->{original_path} ) )
. $data->{original_path};

Expand Down
8 changes: 4 additions & 4 deletions Slim/Web/Cometd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -410,22 +410,22 @@ sub handler {

if ( $result->{error} ) {

my %error = {
my $error = {
channel => '/slim/subscribe',
error => $result->{error},
id => $id,
};

push @errors, \%error;
push @errors, $error;

if ($result->{'errorNeedClient'}) {
$log->error('errorNeedsClient: ', join(', ', $request->[0], @{$request->[1]}));
# Force reconnect because client not connected.
# We should not need to force a new handshake, just a reconect.
# We should not need to force a new handshake, just a reconnect.
# Any successful subscribes will have the acknowledgements in the $events queue
# and others will be retried by the client unpon reconnect.
# Let the client pick the interval to give SlimProto a chance to reconnect.
$error{'advice'} = {
$error->{'advice'} = {
reconnect => 'retry',
};

Expand Down
26 changes: 13 additions & 13 deletions Slim/Web/Pages/Home.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,22 @@ sub home {
if (!main::NOBROWSECACHE && $template eq 'home.html') {
$checksum = md5_hex(Slim::Utils::Unicode::utf8off(join(':',
($client ? $client->id : ''),
$params->{newVersion},
$params->{newPlugins},
$params->{hasLibrary},
$prefs->get('langauge'),
$params->{library_id},
complex_to_query($params->{additionalLinks}),
complex_to_query($params->{additionalLinkOrder}),
$params->{newVersion} || '',
$params->{newPlugins} || '',
$params->{hasLibrary} || '',
$prefs->get('language'),
$params->{library_id} || '',
complex_to_query($params->{additionalLinks} || {}),
complex_to_query($params->{additionalLinkOrder} || {}),
complex_to_query($params->{cookies} || {}),
complex_to_query($params->{favorites} || {}),
$params->{'skinOverride'} || $prefs->get('skin'),
$template,
$params->{song_count},
$params->{album_count},
$params->{artist_count},
$params->{'skinOverride'} || $prefs->get('skin') || '',
$template || '',
$params->{song_count} || 0,
$params->{album_count} || 0,
$params->{artist_count} || 0,
)));

if (my $cached = $cache->get($checksum)) {
return $cached;
}
Expand Down
2 changes: 1 addition & 1 deletion Slim/Web/Pages/Playlist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sub playlist {
$cacheKey = join(':',
$client->id,
$client->currentPlaylistChangeTime(),
$prefs->get('langauge'),
$prefs->get('language'),
$currentSkin,
$params->{'start'},
$songcount,
Expand Down
6 changes: 4 additions & 2 deletions Slim/Web/Settings/Server/FileTypes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sub handler {

# If the conversion pref is enabled confirm that
# it's allowed to be checked.
$paramRef->{$profile} ||= '';
if ($paramRef->{$profile} ne 'DISABLED' && $disabledformats{$profile}) {

if (!Slim::Player::TranscodingHelper::checkBin($profile,'IgnorePrefs')) {
Expand Down Expand Up @@ -96,10 +97,11 @@ sub handler {
$binstring = undef;
}
}

$binstring ||= '';
}iegsx;

if (defined $binstring && $binstring ne '-') {

if ($binstring && $binstring ne '-') {
push @binaries, $binstring;

} elsif ($cmdline eq '-' || $binstring eq '-') {
Expand Down
25 changes: 14 additions & 11 deletions Slim/Web/XMLBrowser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ sub handleFeed {
if (
$subFeed->{'play'}
&& $depth == $levels
&& $stash->{'action'}
&& $stash->{'action'} =~ /^(?:play|add|insert)$/
) {
$subFeed->{'type'} = 'audio';
Expand All @@ -331,6 +332,7 @@ sub handleFeed {
if (
$subFeed->{'playlist'}
&& $depth == $levels
&& $stash->{'action'}
&& $stash->{'action'} =~ /^(?:playall|addall|insert|remove)$/
) {
$subFeed->{'type'} = 'playlist';
Expand Down Expand Up @@ -501,7 +503,7 @@ sub handleFeed {

if ($depth == $levels) {
$args{'index'} = $index;
$args{'quantity'} = $stash->{'itemsPerPage'} || ($stash->{action} =~ /^(?:play|add)all$/i && $prefs->get('maxPlaylistLength')) || $prefs->get('itemsPerPage');
$args{'quantity'} = $stash->{'itemsPerPage'} || ($stash->{action} && $stash->{action} =~ /^(?:play|add)all$/i && $prefs->get('maxPlaylistLength')) || $prefs->get('itemsPerPage');
} elsif ($depth < $levels) {
$args{'index'} = $index[$depth];
$args{'quantity'} = 1;
Expand Down Expand Up @@ -654,7 +656,7 @@ sub handleFeed {
# XXX: Why is $stash->{streaminfo}->{item} added on here, it seems to be undef?
for my $item ( @{ $stash->{'items'} }, $streamItem ) {
my $url;
if ( $item->{'type'} eq 'audio' && $item->{'url'} ) {
if ( $item->{'type'} && $item->{'type'} eq 'audio' && $item->{'url'} ) {
$url = $item->{'url'};
}
elsif ( $item->{'enclosure'} && $item->{'enclosure'}->{'url'} ) {
Expand Down Expand Up @@ -760,8 +762,8 @@ sub handleFeed {

my $itemCount = $feed->{'total'} || scalar @{ $stash->{'items'} };

my $clientId = ( $client ) ? $client->id : undef;
my $otherParams = '&index=' . $crumb[-1]->{index} . '&player=' . $clientId;
my $clientId = ( $client ) ? $client->id : '';
my $otherParams = '&index=' . ($crumb[-1]->{index} || '') . '&player=' . $clientId;
if ( $stash->{'query'} ) {
$otherParams = '&query=' . $stash->{'query'} . $otherParams;
}
Expand Down Expand Up @@ -801,7 +803,7 @@ sub handleFeed {
}

my $item_index = $start;
my $format = $stash->{ajaxSearch} || $stash->{type} eq 'search'
my $format = $stash->{ajaxSearch} || ($stash->{type} || '') eq 'search'
? 'TRACKNUM. TITLE - ALBUM - ARTIST'
: $prefs->get('titleFormat')->[ $prefs->get('titleFormatWeb') ];

Expand All @@ -822,8 +824,8 @@ sub handleFeed {
}

# keep track of station icons
if (
( $_->{play} || $_->{playlist} || ($_->{type} && ($_->{type} eq 'audio' || $_->{type} eq 'playlist')) )
if ( $_->{url} && !ref $_->{url}
&& ( $_->{play} || $_->{playlist} || ($_->{type} && ($_->{type} eq 'audio' || $_->{type} eq 'playlist')) )
&& $_->{url} =~ /^http/
&& $_->{url} !~ m|\.com/api/\w+/v1/opml|
&& ( my $cover = $_->{image} || $_->{cover} )
Expand Down Expand Up @@ -937,7 +939,7 @@ sub handleFeed {

if ($details->{'unfold'}) {
# unfold nested groups of additional items
my $new_index;
my $new_index = 0;
foreach my $group (@{ $details->{'unfold'} }) {

splice @{ $stash->{'items'} }, ($group->{'start'} + $new_index), 1, @{ $group->{'items'} };
Expand All @@ -948,7 +950,7 @@ sub handleFeed {

$feed->{'favorites_url'} ||= $stash->{'playUrl'};

if ($feed->{'hasMetadata'} eq 'album' && $feed->{'albumInfo'}) {
if ($feed->{'hasMetadata'} && $feed->{'hasMetadata'} eq 'album' && $feed->{'albumInfo'}) {

my $morelink = _makeWebLink({ actions => $feed->{'albumInfo'} }, $feed, 'info',
sprintf('%s (%s)', string('INFORMATION'), ($feed->{'album'} || '')));
Expand Down Expand Up @@ -1076,7 +1078,8 @@ sub handleError {

my $template = 'xmlbrowser.html';

my $title = ( uc($params->{title}) eq $params->{title} ) ? Slim::Utils::Strings::getString($params->{title}) : $params->{title};
$params->{title} ||= '';
my $title = ( $params->{title} && uc($params->{title}) eq $params->{title} ) ? Slim::Utils::Strings::getString($params->{title}) : $params->{title};

$stash->{'pagetitle'} = $title;
$stash->{'pageicon'} = $params->{pageicon};
Expand Down Expand Up @@ -1245,7 +1248,7 @@ sub webLink {
push @verbs, 'orderBy:' . $args->{'orderBy'} if $args->{'orderBy'};

my $renderCacheKey;
if ( !main::NOBROWSECACHE && $cacheables{ $args->{path} } && $args->{url_query} !~ /\baction=/ && $args->{url_query} !~ /\bindex=\d+\.\d+\.\d+/ && !Slim::Music::Import->stillScanning() ) {
if ( !main::NOBROWSECACHE && $cacheables{ $args->{path} } && !($args->{url_query} && $args->{url_query} =~ /\baction=/) && !($args->{url_query} && $args->{url_query} =~ /\bindex=\d+\.\d+\.\d+/) && !Slim::Music::Import->stillScanning() ) {

# let cache expire between server restarts
$cacheTimestamp ||= time();
Expand Down

0 comments on commit ff23c8d

Please sign in to comment.