Merge pull request !42 from Stackia/fix-view-count

This commit is contained in:
Discuz! 2017-02-13 12:03:59 +08:00
commit 431d694e43
2 changed files with 4 additions and 2 deletions

View File

@ -20,7 +20,9 @@ class table_forum_threadaddviews extends discuz_table {
}
public function update_by_tid($tid) {
return DB::query('UPDATE %t SET `addviews`=`addviews`+1 WHERE tid=%d', array($this->_table, $tid));
$ret = DB::query('UPDATE %t SET `addviews`=`addviews`+1 WHERE tid=%d', array($this->_table, $tid));
$this->increase_cache(array($tid), array('addviews' => 1));
return $ret;
}
public function fetch_all_order_by_tid($start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t ORDER BY tid'.DB::limit($start, $limit), array($this->_table), $this->_pk);

View File

@ -1034,7 +1034,7 @@ function viewthread_updateviews($tableid) {
if(!$_G['setting']['preventrefresh'] || $_G['cookie']['viewid'] != 'tid_'.$_G['tid']) {
if(!$tableid && $_G['setting']['optimizeviews']) {
if($_G['forum_thread']['addviews']) {
if(isset($_G['forum_thread']['addviews'])) {
if($_G['forum_thread']['addviews'] < 100) {
C::t('forum_threadaddviews')->update_by_tid($_G['tid']);
} else {