/** * Looks for upgrades and saves them as ElggUpgrade entities * * @return boolean $pending_upgrades Are there pending upgrades */ public function run() { $pending_upgrades = false; $plugins = $this->plugins->find('active'); foreach ($plugins as $plugin) { $upgrades = $this->getUpgrades($plugin); if (!empty($upgrades)) { $pending_upgrades = true; } } return $pending_upgrades; }
/** * Populate the boot data * * @param \stdClass $config Elgg CONFIG object * @param \Elgg\Database $db Elgg database * @param EntityTable $entities Entities service * @param Plugins $plugins Plugins service * * @return void * @throws \InstallationException */ public function populate(\stdClass $config, Database $db, EntityTable $entities, Plugins $plugins) { // get subtypes $rows = $db->getData("\n\t\t\tSELECT *\n\t\t\tFROM {$db->prefix}entity_subtypes\n\t\t"); foreach ($rows as $row) { $this->subtype_data[$row->id] = $row; } // get config $rows = $db->getData("\n\t\t\tSELECT *\n\t\t\tFROM {$db->prefix}config\n\t\t"); foreach ($rows as $row) { $this->config_values[$row->name] = unserialize($row->value); } if (!array_key_exists('installed', $this->config_values)) { // try to fetch from old pre 3.0 datalists table // need to do this to be able to perform an upgrade from 2.x to 3.0 try { $rows = $db->getData("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM {$db->prefix}datalists\n\t\t\t\t"); foreach ($rows as $row) { $value = $row->value; if ($row->name == 'processed_upgrades') { // config table already serializes data so no need to double serialize $value = unserialize($value); } $this->config_values[$row->name] = $value; } } catch (\Exception $e) { } } // get site entity $this->site = $entities->get($this->config_values['default_site'], 'site'); if (!$this->site) { throw new \InstallationException("Unable to handle this request. This site is not configured or the database is down."); } // get plugins $this->active_plugins = $plugins->find('active'); // get plugin settings if (!$this->active_plugins) { return; } // find GUIDs with not too many private settings $guids = array_map(function (\ElggPlugin $plugin) { return $plugin->guid; }, $this->active_plugins); // find plugin GUIDs with not too many settings $limit = 40; $set = implode(',', $guids); $sql = "\n\t\t\tSELECT entity_guid\n\t\t\tFROM {$db->prefix}private_settings\n\t\t\tWHERE entity_guid IN ({$set})\n\t\t\t AND name NOT LIKE 'plugin:user_setting:%'\n\t\t\t AND name NOT LIKE 'elgg:internal:%'\n\t\t\tGROUP BY entity_guid\n\t\t\tHAVING COUNT(*) > {$limit}\n\t\t"; $unsuitable_guids = $db->getData($sql, function ($row) { return (int) $row->entity_guid; }); $guids = array_values($guids); $guids = array_diff($guids, $unsuitable_guids); if ($guids) { // get the settings $set = implode(',', $guids); $rows = $db->getData("\n\t\t\t\tSELECT entity_guid, `name`, `value`\n\t\t\t\tFROM {$db->prefix}private_settings\n\t\t\t\tWHERE entity_guid IN ({$set})\n\t\t\t\t AND name NOT LIKE 'plugin:user_setting:%'\n\t\t\t\t AND name NOT LIKE 'elgg:internal:%'\n\t\t\t\tORDER BY entity_guid\n\t\t\t"); // make sure we show all entities as loaded $this->plugin_settings = array_fill_keys($guids, []); foreach ($rows as $i => $row) { $this->plugin_settings[$row->entity_guid][$row->name] = $row->value; } } }