cache to minimize SQL queries in modlog

This commit is contained in:
Michael Save 2012-01-09 10:42:03 +11:00
parent 9ff35f9bc5
commit 7110deb091

View File

@ -296,6 +296,12 @@
'<th>' . _('Action') . '</th>' . '<th>' . _('Action') . '</th>' .
'</tr>'; '</tr>';
while($log = $query->fetch()) { while($log = $query->fetch()) {
$log_id = 'log_' . md5($log['text']);
if($_log = cache::get($log_id))
$log['text'] = $_log;
else {
$log['text'] = utf8tohtml($log['text']); $log['text'] = utf8tohtml($log['text']);
$log['text'] = preg_replace('/(\d+\.\d+\.\d+\.\d+)/', '<a href="?/IP/$1">$1</a>', $log['text']); $log['text'] = preg_replace('/(\d+\.\d+\.\d+\.\d+)/', '<a href="?/IP/$1">$1</a>', $log['text']);
@ -314,6 +320,9 @@
sprintf($config['file_page'], $post['thread']) . '#' . $match[1] sprintf($config['file_page'], $post['thread']) . '#' . $match[1]
: sprintf($config['file_page'], $match[1])) . : sprintf($config['file_page'], $match[1])) .
'">$0</a>', $log['text']); '">$0</a>', $log['text']);
cache::set($log_id, $log['text']);
}
} }
} }
} }