mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 08:34:11 +03:00
Fix calculation of visitor's messages for old threads
This commit is contained in:
parent
57eacfb953
commit
1a137bb683
@ -438,6 +438,7 @@ class Thread
|
|||||||
$thread->modified = $now;
|
$thread->modified = $now;
|
||||||
$thread->closed = $now;
|
$thread->closed = $now;
|
||||||
$thread->state = self::STATE_CLOSED;
|
$thread->state = self::STATE_CLOSED;
|
||||||
|
$thread->messageCount = $thread->getMessageCount();
|
||||||
$thread->save(false);
|
$thread->save(false);
|
||||||
unset($thread);
|
unset($thread);
|
||||||
}
|
}
|
||||||
@ -955,27 +956,13 @@ class Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get messages count
|
|
||||||
$db = Database::getInstance();
|
|
||||||
|
|
||||||
list($message_count) = $db->query(
|
|
||||||
("SELECT COUNT(*) FROM {message} "
|
|
||||||
. "WHERE {message}.threadid = :threadid AND ikind = :kind_user"),
|
|
||||||
array(
|
|
||||||
':threadid' => $this->id,
|
|
||||||
':kind_user' => Thread::KIND_USER,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'return_rows' => Database::RETURN_ONE_ROW,
|
|
||||||
'fetch_type' => Database::FETCH_NUM,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Close thread if it's not already closed
|
// Close thread if it's not already closed
|
||||||
if ($this->state != self::STATE_CLOSED) {
|
if ($this->state != self::STATE_CLOSED) {
|
||||||
$this->state = self::STATE_CLOSED;
|
$this->state = self::STATE_CLOSED;
|
||||||
$this->closed = time();
|
$this->closed = time();
|
||||||
$this->messageCount = $message_count;
|
$this->messageCount = $this->getMessageCount();
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
$args = array('thread' => $this);
|
$args = array('thread' => $this);
|
||||||
@ -1091,6 +1078,32 @@ class Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get actual count of visitor's messages
|
||||||
|
*
|
||||||
|
* @return int Count
|
||||||
|
*/
|
||||||
|
public function getMessageCount()
|
||||||
|
{
|
||||||
|
// Get messages count
|
||||||
|
$db = Database::getInstance();
|
||||||
|
|
||||||
|
list($message_count) = $db->query(
|
||||||
|
("SELECT COUNT(*) FROM {message} "
|
||||||
|
. "WHERE {message}.threadid = :threadid AND ikind = :kind_user"),
|
||||||
|
array(
|
||||||
|
':threadid' => $this->id,
|
||||||
|
':kind_user' => Thread::KIND_USER,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'return_rows' => Database::RETURN_ONE_ROW,
|
||||||
|
'fetch_type' => Database::FETCH_NUM,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $message_count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets thread's fields according to the fields from Database.
|
* Sets thread's fields according to the fields from Database.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user