Fixed bug #11052: Show Warning if memcache is configured but not installed / working...
authorSteffen Kamper <info@sk-typo3.de>
Mon, 15 Jun 2009 08:35:53 +0000 (08:35 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Mon, 15 Jun 2009 08:35:53 +0000 (08:35 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5592 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
typo3/sysext/lang/locallang_core.xml

index caffb55..d01a549 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-15  Steffen Kamper  <info@sk-typo3.de>
+
+       * Fixed bug #11052: Show Warning if memcache is configured but not installed / working on the server
+
 2009-06-14  Steffen Kamper  <info@sk-typo3.de>
 
        * Fixed bug #9984: Element Browser window is MUCH too small (thanks to Georg Kuehnberger)
index 516d047..f15b7be 100644 (file)
@@ -4043,6 +4043,57 @@ final class t3lib_BEfunc {
                                        '</a>');
                        }
 
+                       // Check for memcached if configured
+                       $memCacheUse = false;
+                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'])) {
+                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $table => $conf) {
+                                       if (is_array($conf)) {
+                                               foreach ($conf as $key => $value) {
+                                                       if (!is_array($value) && $value === 't3lib_cache_backend_MemcachedBackend') {
+                                                               $servers = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$table]['options']['servers'];
+                                                               $memCacheUse = true;
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                               }
+                               if ($memCacheUse) {
+                                       $failed = array();
+                                       $defaultPort = ini_get('memcache.default_port');
+                                       if (function_exists('memcache_connect')) {
+                                               if (is_array($servers)) {
+                                                       foreach ($servers as $testServer) {
+                                                               $configuredServer = $testServer;
+                                                               if (substr($testServer, 0, 7) == 'unix://') {
+                                                                       $host = $testServer;
+                                                                       $port = 0;
+                                                               } else {
+                                                                       if (substr($testServer, 0, 6) === 'tcp://') {
+                                                                               $testServer = substr($testServer, 6);
+                                                                       }
+                                                                       if (strstr($testServer, ':') !== FALSE) {
+                                                                               list($host, $port) = explode(':', $testServer, 2);
+                                                                       } else {
+                                                                               $host = $testServer;
+                                                                               $port = $defaultPort;
+                                                                       }
+                                                               }
+                                                               $memcache_obj = @memcache_connect($host, $port);
+                                                               if ($memcache_obj != null) {
+                                                                       memcache_close($memcache_obj);
+                                                               } else {
+                                                                       $failed[] = $configuredServer;
+                                                               }
+                                                       }
+                                               } 
+                                       } 
+                                       if (count($failed) > 0) {
+                                               $warnings['memcached'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.memcache_not_usable') . '<br/>' . 
+                                                       implode(', ', $failed);
+                                       }
+                               }
+                       }
+
                        // Hook for additional warnings
                        if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
                                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
index 53c03dc..ca804e8 100755 (executable)
@@ -245,6 +245,7 @@ Would you like to save now in order to refresh the display?</label>
                        <label index="warning.install_update">This installation is not configured for the TYPO3 version it is running. If you did so intentionally, this message can be safely ignored. If you are unsure, visit the %sUpdate Wizard%s section of the Install Tool to see how TYPO3 would change.</label>
                        <label index="warning.header">Important Notice!</label>
                        <label index="warning.backend_reference">The Reference Index table is empty which is likely the result of a recent TYPO3 upgrade. Please go to %sTools&gt;DB Check%s and update the reference index.</label>
+                       <label index="warning.memcache_not_usable">Memcache is configured, but connection to memcached failed with these configuration(s):</label>
                        <label index="toolbarItems.shortcuts">Shortcuts</label>
                        <label index="toolbarItems.shortcut">Shortcut</label>
                        <label index="toolbarItems.shortcutsGroup">Shortcut Group</label>