summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorMacil Tech <maciltech@gmail.com>2013-03-01 07:12:17 +0800
committerMacil Tech <maciltech@gmail.com>2013-06-18 11:13:43 -0500
commit6fd6b92fe828824dee408614805b35fe29177cd2 (patch)
tree37c7a5324b3348d91468b36b4b48f265eea6e1cb /inc/functions.php
parent1d4fced75acc7a39abdceaf7ea563c2b5d131839 (diff)
Fix openBoard and boardTitle functions using same caching keys.
Added getBoardInfo function that's used by both of the above functions, and can get a board's info without loading it.
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php29
1 files changed, 13 insertions, 16 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 16b16901..872c6c23 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -328,11 +328,19 @@ function setupBoard($array) {
}
function openBoard($uri) {
+ $board = getBoardInfo($uri);
+ if ($board) {
+ setupBoard($board);
+ return true;
+ }
+ return false;
+}
+
+function getBoardInfo($uri) {
global $config;
if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) {
- setupBoard($board);
- return true;
+ return $board;
}
$query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1");
@@ -342,27 +350,16 @@ function openBoard($uri) {
if ($board = $query->fetch()) {
if ($config['cache']['enabled'])
cache::set('board_' . $uri, $board);
- setupBoard($board);
- return true;
+ return $board;
}
return false;
}
function boardTitle($uri) {
- global $config;
- if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) {
+ $board = getBoardInfo($uri);
+ if ($board)
return $board['title'];
- }
-
- $query = prepare("SELECT `title` FROM `boards` WHERE `uri` = :uri LIMIT 1");
- $query->bindValue(':uri', $uri);
- $query->execute() or error(db_error($query));
-
- if ($title = $query->fetch()) {
- return $title['title'];
- }
-
return false;
}