Elgg  Version 6.2
20220825064811_merge_private_settings_in_metadata.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
4 use Phinx\Migration\AbstractMigration;
5 
6 final class MergePrivateSettingsInMetadata extends AbstractMigration {
10  public function change(): void {
11 
12  if (!$this->hasTable('private_settings')) {
13  return;
14  }
15 
16  $prefix = $this->getAdapter()->getOption('table_prefix');
17  $time_created = time();
18 
19  $this->execute("
20  INSERT INTO {$prefix}metadata (entity_guid, name, value, value_type, time_created)
21  SELECT
22  ps.entity_guid AS entity_guid,
23  ps.name AS name,
24  ps.value AS value,
25  'text' AS value_type,
26  {$time_created} AS time_created
27  FROM {$prefix}private_settings ps
28  ");
29 
30  // all data migrated, so drop the table
31  $this->table('private_settings')->drop()->save();
32  }
33 }
change()
Moves private settings to metadata and drops the private settings table.
if(! $user instanceof \ElggUser) $time_created
Definition: online.php:13
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
Definition: robots.php:10