Adding "NoCacheSource"
authorTim Düsterhus <timwolla@arcor.de>
Sun, 25 Sep 2011 16:22:22 +0000 (18:22 +0200)
committerTim Düsterhus <timwolla@arcor.de>
Sun, 25 Sep 2011 16:31:25 +0000 (18:31 +0200)
Disables the cache entirely, useful for debugging purposes.

com.woltlab.wcf/option.xml
wcfsetup/install/files/acp/templates/cacheList.tpl
wcfsetup/install/files/lib/acp/page/CacheListPage.class.php
wcfsetup/install/files/lib/system/cache/source/NoCacheSource.class.php [new file with mode: 0644]
wcfsetup/install/lang/de-informal.xml
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 31812b19edddc4a1b858a1f02ac33ebb7101c0fc..d68febfd1db52720f7f3e71660912f67c24fa51e 100644 (file)
@@ -312,10 +312,12 @@ debug:mail_debug_logfile_path,!mail_use_f_param,!mail_smtp_host,!mail_smtp_port,
                                <defaultvalue><![CDATA[disk]]></defaultvalue>
                                <selectoptions><![CDATA[disk:wcf.acp.option.cache_source_type.disk
 memcache:wcf.acp.option.cache_source_type.memcache
-apc:wcf.acp.option.cache_source_type.apc]]></selectoptions>
+apc:wcf.acp.option.cache_source_type.apc
+no:wcf.acp.option.cache_source_type.no]]></selectoptions>
                                <enableoptions><![CDATA[disk:!cache_source_memcache_host,!cache_source_memcache_use_pconnect,!enable_session_data_cache
 memcache:cache_source_memcache_host,cache_source_memcache_use_pconnect,enable_session_data_cache
-apc:!cache_source_memcache_host,!cache_source_memcache_use_pconnect,!enable_session_data_cache]]></enableoptions>
+apc:!cache_source_memcache_host,!cache_source_memcache_use_pconnect,!enable_session_data_cache
+no:!cache_source_memcache_host,!cache_source_memcache_use_pconnect,!enable_session_data_cache]]></enableoptions>
                        </option>
                        
                        <option name="enable_session_data_cache">
index 9db4419f4f521cd28066a5ebe980e69ff369f463..4f6ba6603385cf51cfb1a6b95f83d5e476b83d2b 100644 (file)
                        <dd>{$cacheData.version}</dd>
                </dl>
        {/if}
-       <dl>
+       {if $cacheData.size}<dl>
                <dt>{lang}wcf.acp.cache.data.size{/lang}</dt>
                <dd>{@$cacheData.size|filesize}</dd>
-       </dl>
-       <dl>
+       </dl>{/if}
+       {if $cacheData.files}<dl>
                <dt>{lang}wcf.acp.cache.data.files{/lang}</dt>
                <dd>{#$cacheData.files}</dd>
-       </dl>
+       </dl>{/if}
        
        {if $additionalFields|isset}{@$additionalFields}{/if}
 </fieldset>
@@ -51,7 +51,7 @@
 <div class="contentHeader">
        <nav class="largeButtons">
                <ul>
-                       <li><a onclick="return confirm('{lang}wcf.acp.cache.clear.sure{/lang}')" href="index.php?action=CacheClear{@SID_ARG_2ND}"><img src="{@RELATIVE_WCF_DIR}icon/delete1.svg" alt="" /> <span>{lang}wcf.acp.cache.button.clear{/lang}</span></a></li>
+                       {if $cacheData.files}<li><a onclick="return confirm('{lang}wcf.acp.cache.clear.sure{/lang}')" href="index.php?action=CacheClear{@SID_ARG_2ND}"><img src="{@RELATIVE_WCF_DIR}icon/delete1.svg" alt="" /> <span>{lang}wcf.acp.cache.button.clear{/lang}</span></a></li>{/if}
                        {if $additionalLargeButtons|isset}{@$additionalLargeButtons}{/if}
                </ul>
        </nav>
@@ -99,7 +99,7 @@
 <div class="contentFooter">
        <nav class="largeButtons">
                <ul>
-                       <li><a onclick="return confirm('{lang}wcf.acp.cache.clear.sure{/lang}')" href="index.php?action=CacheClear{@SID_ARG_2ND}"><img src="{@RELATIVE_WCF_DIR}icon/delete1.svg" alt="" /> <span>{lang}wcf.acp.cache.button.clear{/lang}</span></a></li>
+                       {if $cacheData.files}<li><a onclick="return confirm('{lang}wcf.acp.cache.clear.sure{/lang}')" href="index.php?action=CacheClear{@SID_ARG_2ND}"><img src="{@RELATIVE_WCF_DIR}icon/delete1.svg" alt="" /> <span>{lang}wcf.acp.cache.button.clear{/lang}</span></a></li>{/if}
                        {if $additionalLargeButtons|isset}{@$additionalLargeButtons}{/if}
                </ul>
        </nav>
index 42ff8e5bcd049fa0de5a03930856ca07cf5d1d3b..8b2f735654331df87b7c681531b75e80a9b0d360 100755 (executable)
@@ -167,6 +167,11 @@ class CacheListPage extends AbstractPage {
                                }
                        }
                }
+               // disabled
+               else if ($this->cacheData['source'] == 'wcf\system\cache\source\NoCacheSource') {
+                       $this->cacheData['version'] = WCF_VERSION;
+                       $this->cacheData['files'] = $this->cacheData['size'] = 0;
+               }
        }
        
        /**
diff --git a/wcfsetup/install/files/lib/system/cache/source/NoCacheSource.class.php b/wcfsetup/install/files/lib/system/cache/source/NoCacheSource.class.php
new file mode 100644 (file)
index 0000000..a34f269
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+namespace wcf\system\cache\source;
+
+/**
+ * DevNullCacheSource is an implementation of CacheSource that stores the cache in /dev/null.
+ * 
+ * @author     Tim Düsterhus
+ * @copyright  2011 Tim Düsterhus
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.cache.source
+ * @category   Community Framework
+ */
+class NoCacheSource implements ICacheSource {
+       /**
+        * @see wcf\system\cache\source\ICacheSource::get()
+        */
+       public function get(array $cacheResource) {
+               if (!isset($this->cache[$cacheResource['cache']])) return null;
+
+               return $this->cache[$cacheResource['cache']];
+       }
+       
+       /**
+        * @see wcf\system\cache\source\ICacheSource::set()
+        */
+       public function set(array $cacheResource, $value) {
+               // we have to keep it temporarily
+               $this->cache[$cacheResource['cache']] = $value;
+               $this->loaded[$cacheResource['file']] = true;
+       }
+       
+       /**
+        * @see wcf\system\cache\source\ICacheSource::delete()
+        */
+       public function delete(array $cacheResource) {  
+               // reset open cache
+               if (isset($this->cache[$cacheResource['cache']])) unset($this->cache[$cacheResource['cache']]);
+               if (isset($this->loaded[$cacheResource['file']])) unset($this->loaded[$cacheResource['file']]);
+
+               return;
+       }
+       
+       /**
+        * @see wcf\system\cache\source\ICacheSource::clear()
+        */
+       public function clear($directory, $filepattern) {
+               return;
+       }
+       
+       /**
+        * @see wcf\system\cache\source\ICacheSource::close()
+        */
+       public function close() {
+               return;
+       }
+       
+       /**
+        * @see wcf\system\cache\source\ICacheSource::flush()
+        */
+       public function flush() {
+               return;
+       }
+}
index f734405fd8809c1044a2dc5e0416ed0afcdab668..afd8d1a3995ba7c8a6e26304c956ecc352e535e0 100644 (file)
                <item name="wcf.acp.option.cache_source_type.description"><![CDATA[Bitte wähle die gewünschte Cache-Methode aus! Beachte, dass einige Methoden spezielle Anforderungen an das Server-System stellen und nicht auf jedem Server zur Verfügung stehen.]]></item>
                <item name="wcf.acp.option.cache_source_type.disk"><![CDATA[Dateisystem (Standard)]]></item>
                <item name="wcf.acp.option.cache_source_type.memcache"><![CDATA[Memcache (Experimentell)]]></item>
+               <item name="wcf.acp.option.cache_source_type.no"><![CDATA[Caching deaktivieren (Nicht empfohlen)]]></item>
                <item name="wcf.acp.option.category.general"><![CDATA[Allgemein]]></item>
                <item name="wcf.acp.option.category.general.cache"><![CDATA[Cache]]></item>
                <item name="wcf.acp.option.category.general.cache.description"><![CDATA[]]></item>
index a5022e77214176e9d687f12d93fbea736065a51e..6b7bcc5be2034b8fad26987846de91ec05763e20 100644 (file)
                <item name="wcf.acp.option.cache_source_type.description"><![CDATA[Bitte wählen Sie die gewünschte Cache-Methode aus! Beachten Sie, dass einige Methoden spezielle Anforderungen an das Server-System stellen und nicht auf jedem Server zur Verfügung stehen.]]></item>
                <item name="wcf.acp.option.cache_source_type.disk"><![CDATA[Dateisystem (Standard)]]></item>
                <item name="wcf.acp.option.cache_source_type.memcache"><![CDATA[Memcache]]></item>
+               <item name="wcf.acp.option.cache_source_type.no"><![CDATA[Caching deaktivieren (Nicht empfohlen)]]></item>
                <item name="wcf.acp.option.blacklist_hostnames"><![CDATA[Hostname ausschließen]]></item>
                <item name="wcf.acp.option.blacklist_hostnames.description"><![CDATA[Geben Sie pro Zeile einen Hostname an, die Sie von der Seite ausschließen möchten.]]></item>
                <item name="wcf.acp.option.blacklist_ip_addresses"><![CDATA[IP-Adresse ausschließen]]></item>
index dc5939752b21b3102d51e5de02e75685caf37a19..e473bf343d7ac67047a8d87bbb76d9f16134c6c8 100644 (file)
                <item name="wcf.acp.option.cache_source_type.description"><![CDATA[Please select the type of cache you want to use. Some of the types have special requirements to the server system and cannot be used in your environment.]]></item>
                <item name="wcf.acp.option.cache_source_type.disk"><![CDATA[File system (default)]]></item>
                <item name="wcf.acp.option.cache_source_type.memcache"><![CDATA[Memcache (experimental)]]></item>
+               <item name="wcf.acp.option.cache_source_type.no"><![CDATA[Disable caching (not recommended)]]></item>
                <item name="wcf.acp.option.category.general"><![CDATA[General]]></item>
                <item name="wcf.acp.option.category.general.cache"><![CDATA[Cache]]></item>
                <item name="wcf.acp.option.category.general.cache.description"><![CDATA[]]></item>