Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r19981: LJSUP-9736: Duplicate styles

Committer: gariev
LJSUP-9736: Duplicate styles
A   trunk/bin/misc/delete_s2_style.pl
U   trunk/bin/upgrading/update-db.pl
Added: trunk/bin/misc/delete_s2_style.pl
===================================================================
--- trunk/bin/misc/delete_s2_style.pl	                        (rev 0)
+++ trunk/bin/misc/delete_s2_style.pl	2011-09-07 07:58:49 UTC (rev 19981)
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+use strict;
+use lib "$ENV{LJHOME}/cgi-bin";
+require "ljlib.pl";
+use Data::Dumper;
+use Getopt::Long;
+
+my $need_help;
+my $usage = <<"USAGE";
+$0 - script to delete an S2 style/theme from database
+Usage:
+    $0 <s2lid>
+USAGE
+
+GetOptions(
+    "help"  => \$need_help
+) or die $usage;
+die $usage if $need_help || @ARGV!=1 || int($ARGV[0]) ne $ARGV[0];
+my $s2lid = shift @ARGV;
+
+{
+    print "Are you sure you want to delete layer $s2lid?\n";
+    print " See: http://www.livejournal.com/customize/advanced/layerbrowse.bml?id=$s2lid\n";
+    print " Type yes in capital letters if you are:\n";
+    my $answer = <>;
+    chomp $answer;
+    exit(0) unless $answer eq 'YES';
+}
+
+my $dbh = LJ::get_dbh("master")
+ or die;
+$dbh->{'RaiseError'} = 1;
+
+foreach my $table (qw( s2checker s2compiled s2compiled2 s2info s2layers s2source s2source_inno
+    s2stylelayers s2stylelayers2 s2compiled2 s2stylelayers2 s2compiled2 s2stylelayers2))
+{
+    my $rv = $dbh->do("DELETE FROM $table WHERE s2lid = ?", undef, $s2lid);
+    warn "$rv rows were deleted from $table\n";
+}
+
+foreach my $prefix (qw(s2lo s2c s2sl)) {
+    LJ::MemCache::delete([ $s2lid, "$prefix:$s2lid" ]);
+}
+


Property changes on: trunk/bin/misc/delete_s2_style.pl
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/bin/upgrading/update-db.pl
===================================================================
--- trunk/bin/upgrading/update-db.pl	2011-09-07 07:58:39 UTC (rev 19980)
+++ trunk/bin/upgrading/update-db.pl	2011-09-07 07:58:49 UTC (rev 19981)
@@ -337,7 +337,7 @@
         # find existing re-distributed layers that are in the database
         # and their styleids.
         my $existing = LJ::S2::get_public_layers({ force => 1 }, $sysid);
-
+        
         my %known_id;
         chdir "$ENV{'LJHOME'}/bin/upgrading" or die;
         my %layer;    # maps redist_uniq -> { 'type', 'parent' (uniq), 'id' (s2lid) }
@@ -364,6 +364,8 @@
 
             # remember it so we don't delete it later.
             $known_id{$id} = 1;
+          
+            $existing->{$base}->{'s2lid'} = $id;
 
             $layer{$base} = {
                 'type' => $type,

Tags: gariev, livejournal, pl
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