fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-12-16 05:21 pm

[dw-free] More informative error message when maximum tags is reached

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

http://bugs.dwscoalition.org/show_bug.cgi?id=3278

Instead of telling us that we've exceeded the maximum number of tags, state
how many extra we have, and list the new tags on this entry.

Patch by Erin of [personal profile] teamdestroyer.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/LJ/Tags.pm
--------------------------------------------------------------------------------
diff -r aa7e846f2689 -r af4fb7de068f bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Fri Dec 17 01:04:29 2010 +0800
+++ b/bin/upgrading/en.dat	Fri Dec 17 01:20:43 2010 +0800
@@ -3786,7 +3786,7 @@ taglib.error.mergenoname=You did not pro
 
 taglib.error.mergetoexisting=The tag name '[[tagname]]' is already in use, but you did not select it. Please select the tag or merge to a different tag name.
 
-taglib.error.toomany=This would make you exceed your maximum of [[max]] tags.  Please remove some and try again.
+taglib.error.toomany=This would make you exceed your maximum of [[max]] tags.  Please remove at least [[excess]] of the following new tags: [[tags]].
 
 talk.anonwrote=Someone wrote,
 
diff -r aa7e846f2689 -r af4fb7de068f cgi-bin/LJ/Tags.pm
--- a/cgi-bin/LJ/Tags.pm	Fri Dec 17 01:04:29 2010 +0800
+++ b/cgi-bin/LJ/Tags.pm	Fri Dec 17 01:20:43 2010 +0800
@@ -833,7 +833,11 @@ sub update_logtags {
     my $max = $opts->{ignore_max} ? 0 : $u->count_tags_max;
     if (@to_create && $max && $max > 0) {
         my $total = scalar(keys %$utags) + scalar(@to_create);
-        return $err->(LJ::Lang::ml('taglib.error.toomany', { max => $max })) if $total > $max;
+        if ( $total > $max ) {
+            return $err->(LJ::Lang::ml('taglib.error.toomany', { max => $max, 
+                                                                 tags => join(", ", @to_create), 
+                                                                 excess => $total - $max }));
+        }
     }
 
     # now we can create the new tags, since we know we're safe
@@ -1102,8 +1106,12 @@ sub create_usertag {
     my $max = $opts->{ignore_max} ? 0 : $u->count_tags_max;
     if ($max && $max > 0) {
         my $cur = scalar(keys %{ LJ::Tags::get_usertags($u) || {} });
-        return $err->(LJ::Lang::ml('taglib.error.toomany', { max => $max }))
-            if $cur + scalar(@$tags) > $max;
+        my $tagtotal = $cur + scalar(@$tags);
+        if ($tagtotal > $max) {
+            return $err->(LJ::Lang::ml('taglib.error.toomany', { max => $max, 
+                                                                 tags => join(", ", @$tags) , 
+                                                                 excess => $tagtotal - $max }));
+        }
     }
 
     my $display = $opts->{display} ? 1 : 0;
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org