wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r18488: LJSUP-7829.

Committer: gprochaev
LJSUP-7829.

U   trunk/cgi-bin/LJ/Browse.pm
U   trunk/htdocs/admin/browse/load_all_structure.bml
Modified: trunk/cgi-bin/LJ/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse.pm	2011-03-09 14:08:20 UTC (rev 18487)
+++ trunk/cgi-bin/LJ/Browse.pm	2011-03-10 03:12:57 UTC (rev 18488)
@@ -84,16 +84,11 @@
     my $existcat = LJ::Browse->load_by_url("/browse" . $parentcaturl . $self->{url_path}, $vertical);
     croak("Category exists already") if $existcat;
 
-    $dbh->do("INSERT INTO category SET url_path=?, pretty_name=?, parentcatid=?",
-             undef, $self->{url_path}, $self->{pretty_name}, $self->{parentcatid} || 0);
+    $dbh->do("INSERT INTO category SET url_path=?, pretty_name=?, parentcatid=?, vert_id=?",
+             undef, $self->{url_path}, $self->{pretty_name}, $self->{parentcatid} || 0, $vertical ? $vertical->vert_id : 0);
     die $dbh->errstr if $dbh->err;
     my $catid = $dbh->{mysql_insertid};
 
-    ## Added for Landing Page
-    if ($vertical) {
-        $dbh->do("UPDATE category SET vert_id = ? WHERE catid = ?", undef, $vertical->vert_id, $catid);
-    }
-
     my $tm = $self->typemap;
     # Handle children prop
     if ($self->{parentcatid}) {

Modified: trunk/htdocs/admin/browse/load_all_structure.bml
===================================================================
--- trunk/htdocs/admin/browse/load_all_structure.bml	2011-03-09 14:08:20 UTC (rev 18487)
+++ trunk/htdocs/admin/browse/load_all_structure.bml	2011-03-10 03:12:57 UTC (rev 18488)
@@ -40,7 +40,7 @@
                         $_ =~ s#""#"#;                 ## unescape "
                         $_ 
                     }    
-                    split /;[\s]?/, $line;              ## split line by ,
+                    split /;/, $line;              ## split line by ';'
 
             ## Community name
             my $comm_name = $columns[0];
@@ -49,8 +49,16 @@
             my $vert_name = $columns[1];
             my $vert_url  = $columns[2];
 
-            $ret .= "Ups. May be something wrong in file?" unless $vert_name;
+            unless ($vert_name) {
+                $ret .= "Ups. May be something wrong in file?";
+                last;
+            }
 
+            unless ($vert_url =~ m#^/#) {
+                $ret .= "Url must be started by '/'";
+                last;
+            }
+
             my $v = LJ::Vertical->load_by_url ("/vertical" . $vert_url)
                 || LJ::Vertical->create (name => $vert_name, url => $vert_url);
 
@@ -62,8 +70,8 @@
             ## Category name & url
             my $cat_name = $columns[3];
             my $cat_url = $columns[4];
+
             my $cat = LJ::Browse->load_by_url ("/browse" . $cat_url, $v);
-
             unless ($cat) {
                 $cat = LJ::Browse->create ( pretty_name => $cat_name, url_path => $cat_url, vertical => $v );
             }

Tags: bml, livejournal, pm, wisest-owl
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