mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 13:24:41 +03:00
Use regular tread save in "Thread::closeOldThreads" method
This commit is contained in:
parent
96c9bf2a93
commit
c0232e6fce
@ -394,11 +394,7 @@ class Thread
|
||||
// Get the lock
|
||||
Settings::set('_threads_close_old_lock_time', time());
|
||||
|
||||
$query = "UPDATE {thread} SET "
|
||||
. "lrevision = :next_revision, "
|
||||
. "dtmmodified = :now, "
|
||||
. "dtmclosed = :now, "
|
||||
. "istate = :state_closed "
|
||||
$query = "SELECT * FROM {thread} "
|
||||
. "WHERE istate <> :state_closed "
|
||||
. "AND istate <> :state_left "
|
||||
// Check created timestamp
|
||||
@ -432,18 +428,31 @@ class Thread
|
||||
. ") "
|
||||
. ")";
|
||||
|
||||
// Perform the cleaning
|
||||
Database::getInstance()->query(
|
||||
// Get appropriate threads
|
||||
$now = time();
|
||||
$rows = Database::getInstance()->query(
|
||||
$query,
|
||||
array(
|
||||
':next_revision' => self::nextRevision(),
|
||||
':now' => time(),
|
||||
':now' => $now,
|
||||
':state_closed' => self::STATE_CLOSED,
|
||||
':state_left' => self::STATE_LEFT,
|
||||
':thread_lifetime' => Settings::get('thread_lifetime'),
|
||||
)
|
||||
),
|
||||
array('return_rows' => Database::RETURN_ALL_ROWS)
|
||||
);
|
||||
|
||||
// Perform the cleaning
|
||||
$revision = self::nextRevision();
|
||||
foreach ($rows as $row) {
|
||||
$thread = Thread::createFromDbInfo($row);
|
||||
$thread->lastRevision = $revision;
|
||||
$thread->modified = $now;
|
||||
$thread->closed = $now;
|
||||
$thread->state = self::STATE_CLOSED;
|
||||
$thread->save();
|
||||
unset($thread);
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
Settings::set('_threads_close_old_lock_time', '0');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user