Elgg  Version 3.0
20180609152817_create_site_secret.php
Go to the documentation of this file.
1 <?php
2 
4 
8 class CreateSiteSecret extends AbstractMigration {
9 
13  public function change() {
14 
15  $config_key = \Elgg\Database\SiteSecret::CONFIG_KEY;
16 
17  $prefix = $this->getAdapter()->getOption('table_prefix');
18 
19  $secret = $this->fetchRow("
20  SELECT value
21  FROM {$prefix}config
22  WHERE name = '$config_key'
23  ");
24 
25  if (empty($secret) || empty($secret['value'])) {
26  $crypto = new ElggCrypto();
27  $hash = 'z' . $crypto->getRandomString(31);
28 
29  $this->insert('config', [
30  'name' => $config_key,
31  'value' => serialize($hash),
32  ]);
33  }
34  }
35 }
elgg ElggPriorityList prototype insert
Inserts an element into the priority list at the priority specified.
Create a site secret if one hasn&#39;t been created yet by an Installer.