Elgg  Version master
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 
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 \Elgg\Security\Crypto();
27  $hash = 'z' . $crypto->getRandomString(31);
28 
29  $this->table('config')->insert([[
30  'name' => $config_key,
31  'value' => serialize($hash),
32  ]])->saveData();
33  }
34  }
35 }
Create a site secret if one hasn&#39;t been created yet by an Installer.