Committer: sbelyaev
LJSUP-10208: Incorrect date of Sticky postU trunk/cgi-bin/LJ/DelayedEntry.pm U trunk/cgi-bin/ljlib.pl
Modified: trunk/cgi-bin/LJ/DelayedEntry.pm =================================================================== --- trunk/cgi-bin/LJ/DelayedEntry.pm 2011-10-21 08:41:18 UTC (rev 20401) +++ trunk/cgi-bin/LJ/DelayedEntry.pm 2011-10-21 12:36:05 UTC (rev 20402) @@ -33,13 +33,12 @@ my $poster = $opts->{poster}; $req->{'event'} =~ s/\r\n/\n/g; - my $data_ser = __serialize($journal, $req); - my $journalid = $journal->userid; my $posterid = $poster->userid; my $subject = $req->{subject}; my $posttime = __get_datetime($req); my $dbh = LJ::get_db_writer(); + my $data_ser = $dbh->quote(__serialize($req)); my $delayedid = LJ::alloc_user_counter( $journal, 'Y', @@ -655,9 +654,9 @@ my $posterid = $self->poster->userid; my $subject = $req->{subject}; my $posttime = __get_datetime($req); - my $data_ser = __serialize($self->journal, $req); my $delayedid = $self->{delayed_id}; my $dbh = LJ::get_db_writer(); + my $data_ser = $dbh->quoute(__serialize($req)); my $security = "public"; my $uselogsec = 0; @@ -741,7 +740,7 @@ my $self = bless {}, $class; $self->{journal} = LJ::want_user($opts->{journalid}); - $self->{data} = __deserialize($self->journal, $data_ser); + $self->{data} = __deserialize($data_ser); $self->{poster} = LJ::want_user($opts->{posterid}); $self->{delayed_id} = $delayedid; $self->{posttime} = __get_datetime($self->{data}); @@ -778,7 +777,7 @@ my $req = undef; my $memcache_key = "delayed_entry:$journalid:$delayedid"; - my ($data_ser);# = LJ::MemCache::get($memcache_key); + my ($data_ser) = LJ::MemCache::get($memcache_key); if (!$data_ser) { ($data_ser) = $dbcr->selectrow_array( "SELECT request_stor " . "FROM delayedblob2 ". @@ -790,7 +789,7 @@ } my $self = bless {}, $class; - $self->{data} = __deserialize($journal, $data_ser); + $self->{data} = __deserialize($data_ser); $self->{journal} = $journal; $self->{poster} = LJ::want_user($opts->[2]); $self->{delayed_id} = $delayedid; @@ -1332,23 +1331,23 @@ } sub __serialize { - my ($journal, $req) = @_; - __assert($journal, "no journal"); + my ($req) = @_; __assert($req, "no request"); + $req->{'event'} =~ s/\r\n/\n/g; # compact new-line endings to more comfort chars count near 65535 limit - my $dbcm = LJ::get_cluster_master($journal); + my $ext = $req->{'ext'}; + my $flags = $ext->{'flags'}; + $flags->{'u_owner'} = undef; + $flags->{'u'} = undef; - return $dbcm->quote(Storable::nfreeze($req)); - #return LJ::JSON->to_json( $data ); + return LJ::JSON->to_json( $req ); } sub __deserialize { - my ($journal, $req) = @_; - __assert($journal, "no journal"); + my ($req) = @_; __assert($req, "no request"); - #return LJ::JSON->from_json( $data ); - return Storable::thaw($req); + return LJ::JSON->from_json( $req ); } sub __get_now { Modified: trunk/cgi-bin/ljlib.pl =================================================================== --- trunk/cgi-bin/ljlib.pl 2011-10-21 08:41:18 UTC (rev 20401) +++ trunk/cgi-bin/ljlib.pl 2011-10-21 12:36:05 UTC (rev 20402) @@ -1307,11 +1307,31 @@ if ( $sticky && $show_sticky_on_top ) { if ( !$skip_sticky ) { - warn "sticky $sticky"; my $entry = LJ::Entry->new( $u, 'jitemid' => $sticky ); - $entry->{'itemid'} = $sticky; - push @items, $entry; - push @{$opts->{'entry_objects'}}, $entry; + my $alldatepart; + my $system_alldatepart; + + if ($opts->{'dateformat'} eq "S2") { + $alldatepart = LJ::TimeUtil->alldatepart_s2($entry->eventtime_mysql); + $system_alldatepart = LJ::TimeUtil->alldatepart_s2($entry->logtime_mysql); + } else { + $alldatepart = LJ::TimeUtil->alldatepart_s1($entry->eventtime_mysql); + $system_alldatepart = LJ::TimeUtil->alldatepart_s1($entry->logtime_mysql); + } + + my $item = {'itemid' => $sticky, + 'alldatepart' => $alldatepart, + 'allowmask' => $entry->allowmask, + 'posterid' => $entry->posterid, + 'eventtime' => $entry->eventtime_mysql, + 'system_alldatepart' => $system_alldatepart, + 'security' => $entry->security, + 'anum' => $entry->anum, + 'logtime' => $entry->logtime_mysql, + }; + + push @items, $item; + push @{$opts->{'entry_objects'}}, $item; push @{$opts->{'itemids'}}, $entry->jitemid; } @@ -1355,7 +1375,6 @@ my $entry = LJ::Entry->new($userid, jitemid => $li->{itemid}, rlogtime => $li->{rlogtime}); $entry->absorb_row($li); push @{$opts->{'entry_objects'}}, $entry; - warn LJ::D($entry); } };