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
|
// Get the lock
|
||||||
Settings::set('_threads_close_old_lock_time', time());
|
Settings::set('_threads_close_old_lock_time', time());
|
||||||
|
|
||||||
$query = "UPDATE {thread} SET "
|
$query = "SELECT * FROM {thread} "
|
||||||
. "lrevision = :next_revision, "
|
|
||||||
. "dtmmodified = :now, "
|
|
||||||
. "dtmclosed = :now, "
|
|
||||||
. "istate = :state_closed "
|
|
||||||
. "WHERE istate <> :state_closed "
|
. "WHERE istate <> :state_closed "
|
||||||
. "AND istate <> :state_left "
|
. "AND istate <> :state_left "
|
||||||
// Check created timestamp
|
// Check created timestamp
|
||||||
@ -432,18 +428,31 @@ class Thread
|
|||||||
. ") "
|
. ") "
|
||||||
. ")";
|
. ")";
|
||||||
|
|
||||||
// Perform the cleaning
|
// Get appropriate threads
|
||||||
Database::getInstance()->query(
|
$now = time();
|
||||||
|
$rows = Database::getInstance()->query(
|
||||||
$query,
|
$query,
|
||||||
array(
|
array(
|
||||||
':next_revision' => self::nextRevision(),
|
':now' => $now,
|
||||||
':now' => time(),
|
|
||||||
':state_closed' => self::STATE_CLOSED,
|
':state_closed' => self::STATE_CLOSED,
|
||||||
':state_left' => self::STATE_LEFT,
|
':state_left' => self::STATE_LEFT,
|
||||||
':thread_lifetime' => Settings::get('thread_lifetime'),
|
':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
|
// Release the lock
|
||||||
Settings::set('_threads_close_old_lock_time', '0');
|
Settings::set('_threads_close_old_lock_time', '0');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user