Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Committing fixes

  • Loading branch information...
commit d77f54cfd47befc5d14c22c1cb20ccc405b31981 1 parent 0cedd74
@BrianAker BrianAker authored
View
37 Slash/DB/MySQL/MySQL.pm
@@ -156,12 +156,34 @@ sub init {
}
########################################################
+# Yes, this is ugly, and we can ditch it in about 6 months
+# Turn off autocommit here
+sub sqlTransactionStart {
+ my($self, $arg) = @_;
+ $self->sqlDo($arg);
+}
+
+########################################################
+# Put commit here
+sub sqlTransactionFinish {
+ my($self) = @_;
+ $self->sqlDo("UNLOCK TABLES");
+}
+
+########################################################
+# In another DB put rollback here
+sub sqlTransactionCancel {
+ my($self) = @_;
+ $self->sqlDo("UNLOCK TABLES");
+}
+
+########################################################
# Bad need of rewriting....
sub createComment {
my($self, $form, $user, $pts, $default_user) = @_;
my $sid_db = $self->{_dbh}->quote($form->{sid});
- $self->sqlDo("LOCK TABLES comments WRITE");
+ $self->sqlTransactionStart("LOCK TABLES comments WRITE");
my($maxCid) = $self->sqlSelect(
"max(cid)", "comments", "sid=$sid_db"
);
@@ -173,7 +195,7 @@ sub createComment {
$self->{_dbh}->quote($form->{postercomment}) . "," .
($form->{postanon} ? $default_user : $user->{uid}) . ", $pts,-1,0)";
- $self->sqlDo("UNLOCK TABLES");
+ $self->sqlTransactionFinish();
# don't allow pid to be passed in the form.
# This will keep a pid from being replace by
# with other comment's pid
@@ -1599,7 +1621,7 @@ sub setMetaMod {
my $returns = [];
# Update $muid's Karma
- $self->sqlDo("LOCK TABLES users_info WRITE, metamodlog WRITE");
+ $self->sqlTransactionStart("LOCK TABLES users_info WRITE, metamodlog WRITE");
for (keys %{$m2victims}) {
my $muid = $m2victims->{$_}[0];
my $val = $m2victims->{$_}[1];
@@ -1631,7 +1653,7 @@ sub setMetaMod {
-flag => $flag
});
}
- $self->sqlDo("UNLOCK TABLES");
+ $self->sqlTransactionFinish();
return $returns;
}
@@ -2260,11 +2282,8 @@ sub getStoryList {
my $form = getCurrentForm();
# CHANGE DATE_ FUNCTIONS
- my $sql = q[SELECT storiestuff.hits, commentcount, stories.sid, title, uid,
- date_format(time,"%k:%i") as t,tid,section,
- displaystatus,writestatus,
- date_format(time,"%W %M %d"),
- date_format(time,"%m/%d")
+ my $sql = q[SELECT storiestuff.hits, commentcount, stories.sid, title, uid, time, tid, section,
+ displaystatus,writestatus
FROM stories,storiestuff
WHERE storiestuff.sid=stories.sid];
$sql .= " AND section='$user->{section}'" if $user->{section};
View
26 Slash/DB/Static/MySQL/MySQL.pm
@@ -78,13 +78,13 @@ sub setStoryIndex {
for my $sid (@sids) {
$stories{$sid} = $self->sqlSelectHashref("*","stories","sid='$sid'");
}
- $self->{_dbh}->do("LOCK TABLES newstories WRITE");
+ $self->{_dbh}->sqlTransactionStart("LOCK TABLES newstories WRITE");
foreach my $sid (keys %stories) {
$self->sqlReplace("newstories", $stories{$sid}, "sid='$sid'");
}
- $self->{_dbh}->do("UNLOCK TABLES");
+ $self->{_dbh}->sqlTransactionFinish();
}
########################################################
@@ -213,13 +213,13 @@ sub updateStamps {
my $E = $self->sqlSelectAll($columns, $tables, $where, $other);
- $self->sqlDo("LOCK TABLES users_info WRITE");
+ $self->sqlTransactionStart("LOCK TABLES users_info WRITE");
for (@{$E}) {
my $uid=$_->[0];
$self->setUser($uid, {-lastaccess=>'now()'});
}
- $self->sqlDo("UNLOCK TABLES");
+ $self->sqlTransactionFinish();
}
########################################################
@@ -371,9 +371,7 @@ sub tokens2points {
my $constants = getCurrentStatic();
my @log;
my $c = $self->sqlSelectMany("uid,tokens", "users_info", "tokens >= $constants->{maxtokens}");
- $self->sqlDo("LOCK TABLES users READ,
- users_info WRITE,
- users_comments WRITE");
+ $self->sqlTransactionStart("LOCK TABLES users READ, users_info WRITE, users_comments WRITE");
while (my($uid, $tokens) = $c->fetchrow) {
push @log, ("Giving $constants->{maxtokens}/$constants->{tokensperpoint} " .
@@ -393,13 +391,13 @@ sub tokens2points {
seclev < 100 AND
users.uid=users_comments.uid AND
users.uid=users_info.uid");
- $self->sqlDo("UNLOCK TABLES");
+ $self->sqlTransactionFinish();
- $self->sqlDo("LOCK TABLES users_comments WRITE");
+ $self->sqlTransactionStart("LOCK TABLES users_comments WRITE");
while (my($uid) = $c->fetchrow) {
$self->sqlUpdate("users_comments", { points => 5 } ,"uid=$uid");
}
- $self->sqlDo("UNLOCK TABLES");
+ $self->sqlTransactionFinish();
return \@log;
}
@@ -419,14 +417,14 @@ sub stirPool {
my $revoked = 0;
- $self->sqlDo("LOCK TABLES users_comments WRITE");
+ $self->sqlTransactionStart("LOCK TABLES users_comments WRITE");
while (my($p, $u) = $c->fetchrow) {
$revoked += $p;
$self->sqlUpdate("users_comments", { points => '0' }, "uid=$u");
}
- $self->sqlDo("UNLOCK TABLES");
+ $self->sqlTransactionFinish();
$c->finish;
return 0;
}
@@ -512,14 +510,14 @@ sub giveKarma {
}
- $self->sqlDo("LOCK TABLES users_info WRITE");
+ $self->sqlTransactionStart("LOCK TABLES users_info WRITE");
for (@eligibles) {
next unless $scores[$uid];
$self->setUser($uid, {
-tokens => "tokens+" . $scores[$uid]
});
}
- $self->sqlDo("UNLOCK TABLES");
+ $self->sqlTransactionFinish();
return("Start at $st end at $fi. $eligible left. First score is $cnt");
}
View
5 plugins/Admin/admin.pl
@@ -1117,7 +1117,10 @@ sub listStories {
for (@$storylist) {
($hits, $comments, $sid, $title, $aid, $time, $tid, $section,
- $displaystatus, $writestatus, $td, $td2) = @$_;
+ $displaystatus, $writestatus) = @$_;
+ $time = timeCalc($time, '%H:%M');
+ my $td = timeCalc($time, '%A %B %d');
+ my $td2 = timeCalc($time, '%m/%d');
$substrtid = substr($tid, 0, 5);
Please sign in to comment.
Something went wrong with that request. Please try again.