Bug 6096 Correctly return arrayref from GetAllShelves
authorColin Campbell <colin.campbell@ptfs-europe.com>
Thu, 7 Apr 2011 15:30:17 +0000 (17:30 +0200)
committerChris Nighswonger <chris.nighswonger@gmail.com>
Sat, 16 Apr 2011 18:38:56 +0000 (14:38 -0400)
Follow on from bug 5529 GetAllShelves was also vaguely stuffing
an arrayref into an array
Some signs of cut and paste (unnecessary @params variable)
Calling code now does not have to shuffle the return about
to get the reference. Also removed a debug warn

Signed-off-by: fdurand <frederic.durand@univ-lyon2.fr>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit c0655aabe47cfe21e7846b7a8956db92c1e5b5d2)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>

C4/VirtualShelves.pm
opac/opac-addbybiblionumber.pl

index 5bddadb..6ed7549 100644 (file)
@@ -220,9 +220,9 @@ sub GetRecentShelves {
 
 =head2 GetAllShelves
 
-    ($shelflist) = GetAllShelves($owner)
+    $shelflist = GetAllShelves($owner)
 
-This function returns a references to an array of hashrefs containing all shelves sorted
+This function returns a reference to an array of hashrefs containing all shelves sorted
 by the shelf name.
 
 This function is intended to return a dataset reflecting all the shelves for
@@ -230,15 +230,12 @@ the submitted parameters.
 
 =cut
 
-sub GetAllShelves ($$) {
+sub GetAllShelves {
     my ($category,$owner) = @_;
-    my (@shelflist);
-    my @params = ($category,$owner);
-    my $query = "SELECT * FROM virtualshelves WHERE category = ? AND owner = ? ORDER BY shelfname ASC";
-    my $sth = $dbh->prepare($query);
-    $sth->execute(@params);
-    @shelflist = $sth->fetchall_arrayref({});
-    return ( \@shelflist );
+    my $query = 'SELECT * FROM virtualshelves WHERE category = ? AND owner = ? ORDER BY shelfname ASC';
+    my $sth = $dbh->prepare( $query );
+    $sth->execute( $category, $owner );
+    return $sth->fetchall_arrayref({});
 }
 
 =head2 GetShelf
index 0705c6c..aa425ab 100755 (executable)
@@ -98,19 +98,16 @@ else {
        } else {
 
         my $privateshelves = GetAllShelves(1,$loggedinuser);
-        my @privateshelves = @{$privateshelves};
-        warn scalar($privateshelves);
-        if(@privateshelves){
+        if(@{$privateshelves}){
                        $template->param (
-                               privatevirtualshelves          => @privateshelves,
+                               privatevirtualshelves          => $privateshelves,
                                existingshelves => 1
                        );
                }
         my $publicshelves = GetAllShelves(2,$loggedinuser);
-        my @publicshelves = @{$publicshelves};
-        if(@publicshelves){
+        if(@{$publicshelves}){
                        $template->param (
-                               publicvirtualshelves          => @publicshelves,
+                               publicvirtualshelves          => $publicshelves,
                                existingshelves => 1
                        );
         }