]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Config flag to disable router caching if needed
authorEvan Prodromou <evan@status.net>
Mon, 6 Dec 2010 22:19:41 +0000 (17:19 -0500)
committerEvan Prodromou <evan@status.net>
Mon, 6 Dec 2010 22:19:41 +0000 (17:19 -0500)
README
lib/default.php
lib/router.php

diff --git a/README b/README
index 6343e3e02465c778611b16261b18c7d377d4c71b..3bebb11ee00a56b20f685a223732dde395d1f332 100644 (file)
--- a/README
+++ b/README
@@ -1538,6 +1538,18 @@ external: external links in notices. One of three values: 'sometimes',
     nofollowed on profile, notice, and favorites page. Default is
     'sometimes'.
 
+router
+------
+
+We use a router class for mapping URLs to code. This section controls
+how that router works.
+
+cache: whether to cache the router in memcache (or another caching
+    mechanism). Defaults to true, but may be set to false for
+    developers (who might be actively adding pages, so won't want the
+    router cached) or others who see strange behavior. You're unlikely
+    to need this unless you're a developer.
+
 Plugins
 =======
 
index 7388046d3bfe60ead5986c0b165eec234486cf70..029dbb3906b9fd7c4244c46a41d394afc06f39c1 100644 (file)
@@ -328,4 +328,6 @@ $default =
         array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt')
               'curl' => false, // Use CURL backend for HTTP fetches if available. (If not, PHP's socket streams will be used.)
               ),
+       'router' =>
+       array('cache' => true), // whether to cache the router object. Defaults to true, turn off for devel
         );
index 4b1fdeb92c6f0c5ec220cf597583b7c12a1d83ee..eff88bb46291d1c0d8a1cf28fd828cdac6db5792 100644 (file)
@@ -127,15 +127,19 @@ class Router
     function __construct()
     {
         if (empty($this->m)) {
-            $k = self::cacheKey();
-            $c = Cache::instance();
-            $m = $c->get($k);
-            if (!empty($m)) {
-                $this->m = $m;
-            } else {
+           if (!common_config('router', 'cache')) {
                 $this->m = $this->initialize();
-                $c->set($k, $this->m);
-            }
+           } else {
+               $k = self::cacheKey();
+               $c = Cache::instance();
+               $m = $c->get($k);
+               if (!empty($m)) {
+                   $this->m = $m;
+               } else {
+                   $this->m = $this->initialize();
+                   $c->set($k, $this->m);
+               }
+           }
         }
     }