Committer: ssafronova
LJSUP-6426, LJSUP-6523 - fix time of last update for ExtBlockU trunk/bin/upgrading/update-db-local.pl U trunk/cgi-bin/LJ/ExtBlock.pm
Modified: trunk/bin/upgrading/update-db-local.pl =================================================================== --- trunk/bin/upgrading/update-db-local.pl 2010-08-11 07:40:12 UTC (rev 9328) +++ trunk/bin/upgrading/update-db-local.pl 2010-08-11 08:36:07 UTC (rev 9329) @@ -1913,6 +1913,12 @@ "ALTER TABLE inactive_user ADD INDEX (notices_sent, last_notice_time)"); } + unless (column_type("sup_extblocks", "last_updated")) { + do_alter("sup_extblocks", + "ALTER TABLE sup_extblocks ADD last_updated INT UNSIGNED NOT NULL DEFAULT 0"); + } + + }); 1; # true Modified: trunk/cgi-bin/LJ/ExtBlock.pm =================================================================== --- trunk/cgi-bin/LJ/ExtBlock.pm 2010-08-11 07:40:12 UTC (rev 9328) +++ trunk/cgi-bin/LJ/ExtBlock.pm 2010-08-11 08:36:07 UTC (rev 9329) @@ -32,6 +32,7 @@ ## sub blockid { shift->{blockid} } sub blocktext { shift->{blocktext} } +sub timestamp { shift->{last_updated} } ## ## Class method. Returns a list (arrayref) of all known block IDs @@ -82,12 +83,13 @@ my $text = shift; my $dbh = LJ::get_db_writer(); - my $sth = $dbh->prepare("REPLACE INTO sup_extblocks (blockid, blocktext) VALUES (?, ?)"); + my $sth = $dbh->prepare("REPLACE INTO sup_extblocks (blockid, blocktext, last_updated) VALUES (?, ?, ?)"); - $sth->execute($id, $text) + my $now = time; + $sth->execute($id, $text, $now) or confess 'failed to replace into ext block with id: ' . $id . ', error = ' . $DBI::errstr; - my $self = $class->_new({ blockid => $id, blocktext => $text }); + my $self = $class->_new({ blockid => $id, blocktext => $text, last_updated => $now }); $self->_store_to_memcache; $LJ::REQ_CACHE_EXT_BLOCK{$id} = $self;