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-01 11:32 pm

[dw-free] Allow importing of your journal from another LiveJournal-based site.

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

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

Ignore limit on tags when importing entries.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm
  • cgi-bin/DW/Worker/ContentImporter/Local/Tags.pm
  • cgi-bin/ljprotocol.pl
  • cgi-bin/taglib.pl
--------------------------------------------------------------------------------
diff -r d62f415767a4 -r 6f6d5695a676 cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm
--- a/cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm	Sun Mar 01 19:21:55 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm	Sun Mar 01 23:32:50 2009 +0000
@@ -139,6 +139,7 @@ sub post_event {
             u => $u,
             noauth => 1,
             nonotify => 1,
+            ignore_tags_max => 1,
         }
     );
 
diff -r d62f415767a4 -r 6f6d5695a676 cgi-bin/DW/Worker/ContentImporter/Local/Tags.pm
--- a/cgi-bin/DW/Worker/ContentImporter/Local/Tags.pm	Sun Mar 01 19:21:55 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/Local/Tags.pm	Sun Mar 01 23:32:50 2009 +0000
@@ -36,9 +36,9 @@ sub merge_tags {
     my ( $class, $u, $tags ) = @_;
 
     foreach my $tag ( @{ $tags || [] } ) {
-        LJ::Tags::create_usertag( $u, $tag->{name} );
+        LJ::Tags::create_usertag( $u, $tag->{name}, { ignore_max => 1 } );
     }
 }
 
 
-1;
\ No newline at end of file
+1;
diff -r d62f415767a4 -r 6f6d5695a676 cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl	Sun Mar 01 19:21:55 2009 +0000
+++ b/cgi-bin/ljprotocol.pl	Sun Mar 01 23:32:50 2009 +0000
@@ -1465,6 +1465,7 @@ sub postevent
 
         my $logtag_opts = {
             remote => $u,
+            ignore_max => $flags->{ignore_tags_max} ? 1 : 0,
         };
 
         if (ref $taginput eq 'ARRAY') {
diff -r d62f415767a4 -r 6f6d5695a676 cgi-bin/taglib.pl
--- a/cgi-bin/taglib.pl	Sun Mar 01 19:21:55 2009 +0000
+++ b/cgi-bin/taglib.pl	Sun Mar 01 23:32:50 2009 +0000
@@ -668,7 +668,8 @@ sub get_security_breakdown {
 #           as a comma separated list of user-supplied tags which are then canonicalized
 #           and used.  'remote' is the remote user taking the actions (required).
 #           'err_ref' is ref to scalar to return error messages in.  optional, and may
-#           not be set by all error conditions.
+#           not be set by all error conditions.  'ignore_max' if specified will ignore
+#           a user's max tags limit.
 # returns: 1 on success, undef on error
 # </LJFUNC>
 sub update_logtags {
@@ -780,7 +781,7 @@ sub update_logtags {
 
     # at this point we have enough information to determine if they're going to break their
     # max, so let's do that so we can bail early enough to prevent a rollback operation
-    my $max = $u->get_cap('tags_max');
+    my $max = $opts->{ignore_max} ? 0 : $u->get_cap('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;
@@ -1025,7 +1026,8 @@ sub reset_cache {
 # des-opts: Optional; hashref, possible keys being 'display' and value being whether or
 #           not this tag should be a display tag and 'parenttagid' being the tagid of a
 #           parent tag for hierarchy.  'err_ref' optional key should be a ref to a scalar
-#           where we will store text about errors.
+#           where we will store text about errors.  'ignore_max' if set will ignore the
+#           user's max tags limit when creating this tag.
 # returns: undef on error, else a hashref of { keyword => tagid } for each keyword defined
 # </LJFUNC>
 sub create_usertag {
@@ -1049,7 +1051,7 @@ sub create_usertag {
     return undef unless $isvalid;
 
     # check to ensure we don't exceed the max of tags
-    my $max = $u->get_cap('tags_max');
+    my $max = $opts->{ignore_max} ? 0 : $u->get_cap('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 }))
--------------------------------------------------------------------------------

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