Elgg  Version 3.0
WwwrootSettingMigrator.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Config;
4 
11 
15  public function migrate() {
16  try {
17  $value = false;
18 
19  $sites_table_exists = !empty($this->db->getDataRow("SHOW TABLES LIKE '{$this->db->prefix}sites_entity'"));
20  if ($sites_table_exists) {
21  $row = $this->db->getDataRow("
22  SELECT url FROM {$this->db->prefix}sites_entity
23  WHERE guid = 1
24  ");
25  $value = $row->url;
26  } else {
27  $row = $this->db->getDataRow("
28  SELECT value FROM {$this->db->prefix}metadata
29  WHERE name = 'url' AND
30  entity_guid = 1
31  ");
32  $value = $row->value;
33  }
34 
35  if ($value) {
36  $value = rtrim($value, '/') . '/';
37  $lines = [
38  "",
39  "/**",
40  " * The installation root URL of the site. E.g. https://example.org/elgg/",
41  " *",
42  " * If not provided, this is sniffed from the Symfony Request object",
43  " *",
44  " * @global string \$CONFIG->wwwroot",
45  " */",
46  "\$CONFIG->wwwroot = \"{$value}\";",
47  ""
48  ];
49  $bytes = implode(PHP_EOL, $lines);
50 
51  $this->append($bytes);
52 
53  return $value;
54  } else {
55  error_log("The DB table {$this->db->prefix}metadata did not have an 'url' for the site.");
56  }
57  } catch (\DatabaseException $ex) {
58  error_log($ex->getMessage());
59  }
60  }
61 }
Migrates DB values to settings.php.
append($bytes)
Write bytes to settings files.
Migrates site url database value to settings.php.
$value
Definition: debugging.php:7