Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r23488: LJSUP-14663 (fix production warnings aft...

Committer: ailyin
LJSUP-14663 (fix production warnings after release 100)
U   trunk/cgi-bin/LJ/Lang.pm
Modified: trunk/cgi-bin/LJ/Lang.pm
===================================================================
--- trunk/cgi-bin/LJ/Lang.pm	2012-12-20 07:40:46 UTC (rev 23487)
+++ trunk/cgi-bin/LJ/Lang.pm	2012-12-21 06:43:30 UTC (rev 23488)
@@ -8,6 +8,8 @@
 use base qw( Exporter );
 our @EXPORT_OK = qw( ml );
 
+use Carp qw();
+
 use LJ::LangDatFile;
 use LJ::TimeUtil;
 use LJ::LocalCache;
@@ -916,6 +918,15 @@
     my $lang_short = substr( $lang, 0, 2 );
     my $handler = $PLURAL_FORMS_HANDLERS{$lang_short} || \&plural_form_en;
 
+    unless ( $count =~ /^\d+$/ ) {  
+        my $oldcount = $count;
+        $count =~ s/\D//g;
+        $count ||= 0;
+
+        Carp::carp( qq{Invalid value "$oldcount" } .
+            qq{passed to plural_form, coercing to $count} );
+    }
+
     return $handler->($count);
 }
 
@@ -941,9 +952,6 @@
     my ($count) = @_;
     $count = 0 unless defined $count;
     
-    ## remove the gaps from numbers: 25 500 -> 25500
-    $count =~ s/\s+//g;
-
     return 0 if ( $count % 10 == 1 && $count % 100 != 11 );
     return 1
         if ( $count % 10 >= 2 && $count % 10 <= 4 )

Tags: ailyin, andy, livejournal, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments