# Tricky: we want posts to show up in the index in the same order they were posted.
# If we just bump the posts, the index_timestamps will all be the same, and they'll
# show up in an undefined order. We don't want to do this in the ORDER BY when
# searching, because that's too expensive. Instead, tweak the timestamps slightly:
# for each post updated, set the index_timestamps 1ms newer than the previous.
#
# Returns the number of posts actually activated.
$count=0;
# Original function is kinda confusing...
# If anyone knows a better way to do this, it'll be welcome.
sort($post_ids);
$s=1;
$timestamp=strtotime(self::connection()->selectValue("SELECT index_timestamp FROM posts ORDER BY id DESC LIMIT 1"));
foreach($post_idsas$id){
$timestamp+=$s;
$params=array_merge(array('UPDATE posts SET index_timestamp = ?, is_held = 0 WHERE '.implode(' AND ',$conds)),array(date('Y-m-d H:i:s',$timestamp)),$cond_params,array($id));
self::connection()->executeSql($params);
$count++;
$s++;
}
if($count>0)
Moebooru\CacheHelper::expire();
return$count;
}
publicfunctionupdate_status_on_destroy()
{
# Can't use updateAttributes here since this method is wrapped inside of a destroy call
self::connection()->executeSql("UPDATE posts SET status = ? WHERE id = ?",'deleted',$this->id);