summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/bans.php2
-rw-r--r--inc/config.php9
-rwxr-xr-xinc/functions.php40
3 files changed, 44 insertions, 7 deletions
diff --git a/inc/bans.php b/inc/bans.php
index 87e06e28..c468eb64 100644
--- a/inc/bans.php
+++ b/inc/bans.php
@@ -166,7 +166,7 @@ class Bans {
if ($ban['post']) {
$post = json_decode($ban['post']);
- $ban['message'] = $post->body;
+ $ban['message'] = isset($post->body) ? $post->body : 0;
}
unset($ban['ipstart'], $ban['ipend'], $ban['post'], $ban['creator']);
diff --git a/inc/config.php b/inc/config.php
index 91804429..5926eb1d 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -103,7 +103,7 @@
/*
* ====================
- * Cache settings
+ * Cache, lock and queue settings
* ====================
*/
@@ -120,6 +120,7 @@
// $config['cache']['enabled'] = 'apc';
// $config['cache']['enabled'] = 'memcached';
// $config['cache']['enabled'] = 'redis';
+ // $config['cache']['enabled'] = 'fs';
// Timeout for cached objects such as posts and HTML.
$config['cache']['timeout'] = 60 * 60 * 48; // 48 hours
@@ -142,6 +143,12 @@
// (this file will be explicitly loaded during cache hit, but not during cache miss).
$config['cache_config'] = false;
+ // Define a lock driver.
+ $config['lock']['enabled'] = 'fs';
+
+ // Define a queue driver.
+ $config['queue']['enabled'] = 'fs'; // xD
+
/*
* ====================
* Cookie settings
diff --git a/inc/functions.php b/inc/functions.php
index 8329e774..0cfdb72f 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -19,6 +19,8 @@ require_once 'inc/database.php';
require_once 'inc/events.php';
require_once 'inc/api.php';
require_once 'inc/mod/auth.php';
+require_once 'inc/lock.php';
+require_once 'inc/queue.php';
require_once 'inc/polyfill.php';
@include_once 'inc/lib/parsedown/Parsedown.php'; // fail silently, this isn't a critical piece of code
@@ -93,6 +95,8 @@ function loadConfig() {
'db',
'api',
'cache',
+ 'lock',
+ 'queue',
'cookies',
'error',
'dir',
@@ -1749,7 +1753,6 @@ function buildJavascript() {
function checkDNSBL() {
global $config;
-
if (isIPv6())
return; // No IPv6 support yet.
@@ -2806,17 +2809,17 @@ function generation_strategy($fun, $array=array()) { global $config;
$action = false;
foreach ($config['generation_strategies'] as $s) {
- if ($strategy = $s($fun, $array)) {
+ if ($action = $s($fun, $array)) {
break;
}
}
- switch ($strategy[0]) {
+ switch ($action[0]) {
case 'immediate':
return 'rebuild';
case 'defer':
// Ok, it gets interesting here :)
- Queue::add(serialize(array('build', $fun, $array)));
+ get_queue('generate')->push(serialize(array('build', $fun, $array, $action)));
return 'ignore';
case 'build_on_load':
return 'delete';
@@ -2832,5 +2835,32 @@ function strategy_smart_build($fun, $array) {
}
function strategy_sane($fun, $array) { global $config;
- return false;
+ // Well, ideally a sane strategy would involve a more stringent checking,
+ // but let's at least have something to get the ball rolling :^)
+
+ if (php_sapi_name() == 'cli') return false;
+ else if (isset($_POST['mod']) || isset($_POST['json_response'])) return false;
+ else if ($fun == 'sb_thread' || ($fun == 'sb_board' && $array[1] == 1)) return array('immediate');
+ else return false;
+}
+
+// My first, test strategy.
+function strategy_first($fun, $array) {
+ switch ($fun) {
+ case 'sb_thread':
+ return array('defer');
+ case 'sb_board':
+ if ($array[1] > 8) return array('build_on_load');
+ else return array('defer');
+ case 'sb_api':
+ return array('defer');
+ case 'sb_catalog':
+ return array('defer');
+ case 'sb_recent':
+ return array('build_on_load');
+ case 'sb_sitemap':
+ return array('build_on_load');
+ case 'sb_ukko':
+ return array('defer');
+ }
}