From fceea15317af1cb00044a927080e1c5def12304e Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 18 Oct 2014 13:21:08 -0700 Subject: [PATCH] Be smarter about rebuilds --- inc/functions.php | 2 +- inc/instance-config.php | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index b61f5bb7..b2d945d2 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -680,7 +680,7 @@ function listBoards($just_uri = false, $indexed_only = false) { if (!$just_uri) { $query = query("SELECT ``boards``.`uri` uri, ``boards``.`title` title, ``boards``.`subtitle` subtitle, ``board_create``.`time` time, ``boards``.`indexed` indexed FROM ``boards``" . ( $indexed_only ? " WHERE `indexed` = 1 " : "" ) . "LEFT JOIN ``board_create`` ON ``boards``.`uri` = ``board_create``.`uri` ORDER BY ``boards``.`uri`") or error(db_error()); - $boards = $query->fetchAll(); + $boards = $query->fetchAll(PDO::FETCH_ASSOC); } else { $boards = array(); $query = query("SELECT `uri` FROM ``boards``" . ( $indexed_only ? " WHERE `indexed` = 1" : "" ) . " ORDER BY ``boards``.`uri`") or error(db_error()); diff --git a/inc/instance-config.php b/inc/instance-config.php index 0a557691..c2df3b5b 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -355,13 +355,22 @@ EOT; file_write('stylesheets/board/'.$b.'.css', $_POST['css']); file_write($b.'/rules.html', Element('page.html', array('title'=>'Rules', 'subtitle'=>'', 'config'=>$config, 'body'=>'
'.purify($_POST['rules']).'
'))); file_write($b.'/rules.txt', $_POST['rules']); + + $_config = $config; + openBoard($b); - buildIndex(); - buildJavascript(); - $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $b)) or error(db_error()); - while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - buildThread($post['id']); + + // be smarter about rebuilds...only some changes really require us to rebuild all threads + if ($_config['blotter'] != $config['blotter'] || $_config['field_disable_name'] != $config['field_disable_name'] || $_config['show_sages'] != $config['show_sages']) { + buildIndex(); + $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $b)) or error(db_error()); + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + buildThread($post['id']); + } } + + buildJavascript(); + modLog('Edited board settings', $b); }