Revert "smart_build: buildThread" (for a moment, something b0rks)
This reverts commit f2a74812f0
.
This commit is contained in:
parent
f2a74812f0
commit
b246daa191
@ -2068,62 +2068,51 @@ function buildThread($id, $return = false, $mod = false) {
|
|||||||
cache::delete("thread_{$board['uri']}_{$id}");
|
cache::delete("thread_{$board['uri']}_{$id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$config['smart_build'] || $return || $mod) {
|
$query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri']));
|
||||||
$query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri']));
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
$query->execute() or error(db_error($query));
|
||||||
$query->execute() or error(db_error($query));
|
|
||||||
|
|
||||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if (!isset($thread)) {
|
if (!isset($thread)) {
|
||||||
$thread = new Thread($post, $mod ? '?/' : $config['root'], $mod);
|
$thread = new Thread($post, $mod ? '?/' : $config['root'], $mod);
|
||||||
} else {
|
} else {
|
||||||
$thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod));
|
$thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if any posts were found
|
// Check if any posts were found
|
||||||
if (!isset($thread))
|
if (!isset($thread))
|
||||||
error($config['error']['nonexistant']);
|
error($config['error']['nonexistant']);
|
||||||
|
|
||||||
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
||||||
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
||||||
|
|
||||||
$body = Element('thread.html', array(
|
$body = Element('thread.html', array(
|
||||||
'board' => $board,
|
'board' => $board,
|
||||||
'thread' => $thread,
|
'thread' => $thread,
|
||||||
'body' => $thread->build(),
|
'body' => $thread->build(),
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'mod' => $mod,
|
'mod' => $mod,
|
||||||
'hasnoko50' => $hasnoko50,
|
'hasnoko50' => $hasnoko50,
|
||||||
'isnoko50' => false,
|
'isnoko50' => false,
|
||||||
'antibot' => $antibot,
|
'antibot' => $antibot,
|
||||||
'boardlist' => createBoardlist($mod),
|
'boardlist' => createBoardlist($mod),
|
||||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($config['try_smarter'] && !$mod)
|
if ($config['try_smarter'] && !$mod)
|
||||||
$build_pages[] = thread_find_page($id);
|
$build_pages[] = thread_find_page($id);
|
||||||
|
|
||||||
// json api
|
// json api
|
||||||
if ($config['api']['enabled']) {
|
if ($config['api']['enabled']) {
|
||||||
$api = new Api();
|
$api = new Api();
|
||||||
$json = json_encode($api->translateThread($thread));
|
$json = json_encode($api->translateThread($thread));
|
||||||
$jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json';
|
|
||||||
file_write($jsonFilename, $json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json';
|
$jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json';
|
||||||
file_unlink($jsonFilename);
|
file_write($jsonFilename, $json);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['smart_build'] && !$return && !$mod) {
|
if ($return) {
|
||||||
$noko50fn = $board['dir'] . $config['dir']['res'] . link_for(array('id' => $id), true);
|
|
||||||
file_unlink($noko50fn);
|
|
||||||
|
|
||||||
file_unlink($board['dir'] . $config['dir']['res'] . link_for(array('id' => $id)));
|
|
||||||
} else if ($return) {
|
|
||||||
return $body;
|
return $body;
|
||||||
} else {
|
} else {
|
||||||
$noko50fn = $board['dir'] . $config['dir']['res'] . link_for($thread, true);
|
$noko50fn = $board['dir'] . $config['dir']['res'] . link_for($thread, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user