mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-03-29 09:46 pm

[dw-free] Fix use of uninitialized arrayref.

[commit: http://hg.dwscoalition.org/dw-free/rev/070debda1b83]

Fix use of uninitialized arrayref.

Patch by [staff profile] mark.

Files modified:
  • htdocs/support/see_request.bml
--------------------------------------------------------------------------------
diff -r 4a759f0be502 -r 070debda1b83 htdocs/support/see_request.bml
--- a/htdocs/support/see_request.bml	Sun Mar 29 17:29:55 2009 +0000
+++ b/htdocs/support/see_request.bml	Sun Mar 29 21:46:37 2009 +0000
@@ -716,7 +716,7 @@ body<=
 
         foreach my $f ( LJ::Faq->load_all( lang => $curlang ) ) {
             $f->render_in_place( { user => $user, url => $user_url } );
-            push @{ $faqq{ $f->faqcat } }, $f;
+            push @{ $faqq{$f->faqcat} ||= [] }, $f;
         }
 
         my @faqlist = ('0', "(don't reference FAQ)");
@@ -724,7 +724,7 @@ body<=
         {
             push @faqlist, ('0', "[ $faqcat{$faqcat}->{'faqcatname'} ]");
             foreach my $faq ( sort { $a->sortorder <=> $b->sortorder }
-                                   @{ $faqq{$faqcat} } ) {
+                                   @{ $faqq{$faqcat} || [] } ) {
                 my $q = $faq->question_html;
                 next unless $q;
                 $q = "... $q";
--------------------------------------------------------------------------------
ext_78: A picture of a plush animal. It looks a bit like a cross between a duck and a platypus. (Default)

[identity profile] pne.livejournal.com 2009-03-30 04:53 am (UTC)(link)
The push should be fine; the arrayref should get autovivified without comment when you assign to it; reading is what will give you the warning (IIRC).

Though initialising the arrayref explicitly in the push doesn't hurt, of course.