kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2009-07-28 11:48 pm

[dw-free] Creating a custom mood theme only allows urls of up to 101 characters

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

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

Enforce new mood theme URL limit of 200 characters.

Patch by [personal profile] yvi.

Files modified:
  • bin/upgrading/update-db-general.pl
  • cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm
--------------------------------------------------------------------------------
diff -r 896d4a9b6a82 -r dc52fa288638 bin/upgrading/update-db-general.pl
--- a/bin/upgrading/update-db-general.pl	Tue Jul 28 15:16:20 2009 +0000
+++ b/bin/upgrading/update-db-general.pl	Tue Jul 28 18:48:15 2009 -0500
@@ -248,7 +248,7 @@ CREATE TABLE moodthemedata (
 CREATE TABLE moodthemedata (
     moodthemeid int(10) unsigned NOT NULL default '0',
     moodid int(10) unsigned NOT NULL default '0',
-    picurl varchar(100) default NULL,
+    picurl varchar(200) default NULL,
     width tinyint(3) unsigned NOT NULL default '0',
     height tinyint(3) unsigned NOT NULL default '0',
 
@@ -3456,6 +3456,12 @@ register_alter(sub {
                  "MODIFY keyword VARCHAR(80) BINARY NOT NULL");
     }
 
+    #allow longer moodtheme pic URLs
+    if (column_type("moodthemedata", "picurl") eq "varchar(100)") {
+        do_alter("moodthemedata",
+                 "ALTER TABLE moodthemedata MODIFY picurl VARCHAR(200)");
+    }
+
     # change interest.interest key to being unique, if it's not already
     {
         my $sth = $dbh->prepare("SHOW INDEX FROM interests");
diff -r 896d4a9b6a82 -r dc52fa288638 cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm
--- a/cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm	Tue Jul 28 15:16:20 2009 +0000
+++ b/cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm	Tue Jul 28 18:48:15 2009 -0500
@@ -45,6 +45,8 @@ sub execute {
     if (!$picurl || $width == 0 || $height == 0) {
         $dbh->do("DELETE FROM moodthemedata WHERE moodthemeid = ? AND moodid= ?", undef, $themeid, $moodid);
         $self->print("Data deleted for theme #$themeid, mood #$moodid.");
+    } elsif ( length($picurl) > 200 ) {
+        $self->error("Moodpic URLs cannot exceed 200 characters.");
     } else {
         $dbh->do("REPLACE INTO moodthemedata (moodthemeid, moodid, picurl, width, height) VALUES (?, ?, ?, ?, ?)",
                  undef, $themeid, $moodid, $picurl, $width, $height);
--------------------------------------------------------------------------------