public function indexAction()
 {
     Kwf_Util_MemoryLimit::set(512);
     Kwf_Events_ModelObserver::getInstance()->disable();
     //try to update old-style db config
     if (file_exists('config.db.ini')) {
         $db = file_get_contents('config.db.ini');
         if (file_exists('config.local.ini')) {
             $c = file_get_contents('config.local.ini');
         } else {
             $c = "[production]\n";
         }
         $c .= "\n";
         $db = str_replace("[database]\n", '', $db);
         foreach (explode("\n", trim($db)) as $line) {
             if (trim($line)) {
                 $c .= "database." . $line . "\n";
             }
         }
         file_put_contents('config.local.ini', $c);
         unlink('config.db.ini');
     }
     if ($this->_getParam('rev')) {
         throw new Kwf_Exception("rev parameter is not supported anymore");
     }
     if ($this->_getParam('class')) {
         throw new Kwf_Exception("class parameter is not supported anymore");
     }
     $skipClearCache = $this->_getParam('skip-clear-cache');
     $doneNames = Kwf_Util_Update_Helper::getExecutedUpdatesNames();
     if ($this->_getParam('name')) {
         $updates = Kwf_Util_Update_Helper::getUpdates();
         foreach ($updates as $k => $u) {
             $n = $u->getUniqueName();
             $n = substr($n, strrpos($n, '_') + 1);
             if ($n != $this->_getParam('name')) {
                 unset($updates[$k]);
             }
         }
     } else {
         if (!$skipClearCache) {
             Kwf_Util_ClearCache::getInstance()->clearCache(array('types' => 'all', 'output' => true, 'refresh' => false));
         }
         echo "Looking for update-scripts...";
         $updates = Kwf_Util_Update_Helper::getUpdates();
         foreach ($updates as $k => $u) {
             if (in_array($u->getUniqueName(), $doneNames) || $u->getLegacyName() && in_array($u->getLegacyName(), $doneNames)) {
                 unset($updates[$k]);
             }
         }
         echo " found " . count($updates) . "\n\n";
     }
     if (!$this->_getParam('debug')) {
         Kwf_Util_Maintenance::writeMaintenanceBootstrap();
     }
     $c = new Zend_ProgressBar_Adapter_Console();
     $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT));
     $c->setTextWidth(50);
     $runner = new Kwf_Util_Update_Runner($updates);
     $progress = new Zend_ProgressBar($c, 0, $runner->getProgressSteps());
     $runner->setProgressBar($progress);
     $runner->setVerbose(true);
     $runner->setEnableDebug($this->_getParam('debug'));
     $runner->setSkipClearCache($skipClearCache);
     if (!$runner->checkUpdatesSettings()) {
         echo "\ncheckSettings failed, update stopped\n";
     } else {
         $executedUpdates = $runner->executeUpdates();
         echo "\nupdate finished\n";
         $doneNames = array_unique(array_merge($doneNames, $executedUpdates));
         $runner->writeExecutedUpdates($doneNames);
     }
     if (!$this->_getParam('debug')) {
         Kwf_Util_Maintenance::restoreMaintenanceBootstrap();
     }
     $errors = $runner->getErrors();
     if ($errors) {
         echo "\n\n" . str_repeat('=', 16) . "\n";
         echo count($errors) . " update script(s) failed:\n";
         foreach ($errors as $error) {
             echo $error['name'] . ": \n";
             echo $error['message'] . "\n\n";
         }
         exit(1);
     } else {
         echo "\n" . count($updates) . " update script(s) successfully executed.\n";
         exit(0);
     }
 }
 /**
  * @param array possible options: types(=all), output(=false), refresh(=true), excludeTypes, skipMaintenanceBootstrap, skipOtherServers
  */
 public final function clearCache(array $options)
 {
     $typeNames = $options['types'];
     $output = isset($options['output']) ? $options['output'] : false;
     $refresh = isset($options['refresh']) ? $options['refresh'] : false;
     $excludeTypes = isset($options['excludeTypes']) ? $options['excludeTypes'] : array();
     Kwf_Events_ModelObserver::getInstance()->disable();
     Kwf_Util_MemoryLimit::set(512);
     if (!isset($options['skipMaintenanceBootstrap']) || !$options['skipMaintenanceBootstrap']) {
         Kwf_Util_Maintenance::writeMaintenanceBootstrap($output);
     }
     if ($typeNames == 'all') {
         $types = $this->getTypes();
     } else {
         if (!is_array($typeNames)) {
             $typeNames = explode(',', $typeNames);
         }
         $types = array();
         foreach ($this->getTypes() as $t) {
             if (in_array($t->getTypeName(), $typeNames)) {
                 $types[] = $t;
             }
         }
     }
     if (is_string($excludeTypes)) {
         $excludeTypes = explode(',', $excludeTypes);
     }
     foreach ($types as $k => $i) {
         if (in_array($i->getTypeName(), $excludeTypes)) {
             unset($types[$k]);
         }
     }
     $maxTypeNameLength = 0;
     $countSteps = 0;
     foreach ($types as $type) {
         $type->setVerbosity($output ? Kwf_Util_ClearCache_Types_Abstract::VERBOSE : Kwf_Util_ClearCache_Types_Abstract::SILENT);
         $maxTypeNameLength = max($maxTypeNameLength, strlen($type->getTypeName()));
         if ($type->doesClear()) {
             $countSteps++;
         }
         if ($type->doesRefresh()) {
             $countSteps++;
         }
     }
     $progress = null;
     if (isset($options['progressAdapter'])) {
         $progress = new Zend_ProgressBar($options['progressAdapter'], 0, $countSteps);
     }
     $currentStep = 0;
     foreach ($types as $type) {
         if ($type->doesClear()) {
             $currentStep++;
             if ($progress) {
                 $progress->next(1, "clearing " . $type->getTypeName());
             }
             if ($output) {
                 echo "[" . str_repeat(' ', 2 - strlen($currentStep)) . "{$currentStep}/{$countSteps}] ";
                 echo "clearing " . $type->getTypeName() . "..." . str_repeat('.', $maxTypeNameLength - strlen($type->getTypeName())) . " ";
             }
             $t = microtime(true);
             $type->clearCache($options);
             if ($output) {
                 if ($type->getSuccess()) {
                     echo "OK";
                 } else {
                     echo " [ERROR]";
                 }
                 echo " (" . round((microtime(true) - $t) * 1000) . "ms)";
                 echo "\n";
             }
         }
     }
     if ($refresh) {
         foreach ($types as $type) {
             if ($type->doesRefresh()) {
                 $currentStep++;
                 if ($progress) {
                     $progress->next(1, "refreshing " . $type->getTypeName());
                 }
                 if ($output) {
                     echo "[{$currentStep}/{$countSteps}] refreshing " . $type->getTypeName() . "." . str_repeat('.', $maxTypeNameLength - strlen($type->getTypeName())) . " ";
                 }
                 $t = microtime(true);
                 $mem = memory_get_usage();
                 $type->refreshCache($options);
                 if ($output) {
                     if ($type->getSuccess()) {
                         echo "OK";
                     } else {
                         echo " [ERROR]";
                     }
                     echo " (" . round((microtime(true) - $t) * 1000) . "ms";
                     if (memory_get_usage() - $mem > 1024 * 1024) {
                         echo ", " . round((memory_get_usage() - $mem) / (1024 * 1024), 2) . "MB";
                     }
                     echo ")\n";
                 }
             }
         }
     }
     /*
             TODO re-enable this somehow
               * required at all?
               * own type? or should the different types each also clear the other servers (apc does that already)
     
             $skipOtherServers = isset($options['skipOtherServers']) ? $options['skipOtherServers'] : false;
             if (Kwf_Config::getValue('server.aws') && !$skipOtherServers) {
                 $otherHostsTypes = $this->_getCacheDirs();
                 //add other types
                 $otherHostsTypes[] = 'config';
                 $otherHostsTypes[] = 'setup';
                 $otherHostsTypes[] = 'component';
                 $otherHostsTypes[] = 'events';
                 $otherHostsTypes[] = 'trl';
                 $otherHostsTypes = array_unique($otherHostsTypes);
                 if (in_array('all', $types)) {
                     //use all of $otherHostsTypes
                 } else {
                     $otherHostsTypes = array_intersect($otherHostsTypes, $types);
                 }
                 if ($otherHostsTypes) {
                     $domains = Kwf_Util_Aws_Ec2_InstanceDnsNames::getOther();
                     foreach ($domains as $domain) {
                         if ($output) {
                             echo "executing clear-cache on $domain:\n";
                         }
                         $cmd = Kwf_Config::getValue('server.phpCli')." bootstrap.php clear-cache --type=".implode(',', $otherHostsTypes).' --skip-other-servers';
                         $cmd = "ssh -o 'StrictHostKeyChecking no' $domain ".escapeshellarg('cd '.Kwf_Config::getValue('server.dir').'; '.$cmd);
                         passthru($cmd);
                         if ($output) {
                             echo "\n";
                         }
                     }
                 }
             }
     */
     if (!isset($options['skipMaintenanceBootstrap']) || !$options['skipMaintenanceBootstrap']) {
         Kwf_Util_Maintenance::restoreMaintenanceBootstrap($output);
     }
     Kwf_Events_ModelObserver::getInstance()->enable();
     return $types;
 }