Example #1
0
 /**
  * Do a minimal engine load
  *
  * @return void
  */
 protected function setupSimplecache()
 {
     if (!empty($this->config->dataroot) && isset($this->config->simplecache_enabled)) {
         return;
     }
     $db_config = new Database\Config($this->config);
     $db = new Database($db_config, new Logger(new PluginHooksService()));
     try {
         $rows = $db->getData("\n\t\t\t\tSELECT `name`, `value`\n\t\t\t\tFROM {$db->getTablePrefix()}datalists\n\t\t\t\tWHERE `name` IN ('dataroot', 'simplecache_enabled')\n\t\t\t");
         if (!$rows) {
             $this->send403('Cache error: unable to get the data root');
         }
     } catch (\DatabaseException $e) {
         if (0 === strpos($e->getMessage(), "Elgg couldn't connect")) {
             $this->send403('Cache error: unable to connect to database server');
         } else {
             $this->send403('Cache error: unable to connect to Elgg database');
         }
         exit;
         // unnecessary, but helps PhpStorm understand
     }
     foreach ($rows as $row) {
         $this->config->{$row->name} = $row->value;
     }
     if (empty($this->config->dataroot)) {
         $this->send403('Cache error: unable to get the data root');
     }
 }