Elgg  Version 2.3
upgrade.php
Go to the documentation of this file.
1 <?php
20 function elgg_set_processed_upgrades(array $processed_upgrades) {
21  $processed_upgrades = array_unique($processed_upgrades);
22  return datalist_set('processed_upgrades', serialize($processed_upgrades));
23 }
24 
34  preg_match('/^([0-9]{10})([\.a-z0-9-_]+)?\.(php)$/i', $filename, $matches);
35 
36  if (isset($matches[1])) {
37  return (int) $matches[1];
38  }
39 
40  return false;
41 }
42 
52 function elgg_get_upgrade_files($upgrade_path = null) {
53  if (!$upgrade_path) {
54  $upgrade_path = elgg_get_engine_path() . '/lib/upgrades/';
55  }
56  $upgrade_path = sanitise_filepath($upgrade_path);
57  $handle = opendir($upgrade_path);
58 
59  if (!$handle) {
60  return false;
61  }
62 
63  $upgrade_files = array();
64 
65  while ($upgrade_file = readdir($handle)) {
66  // make sure this is a well formed upgrade.
67  if (is_dir($upgrade_path . '$upgrade_file')) {
68  continue;
69  }
70  $upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
71  if (!$upgrade_version) {
72  continue;
73  }
74  $upgrade_files[] = $upgrade_file;
75  }
76 
77  sort($upgrade_files);
78 
79  return $upgrade_files;
80 }
81 
91  delete_data("drop table {$CONFIG->dbprefix}upgrade_lock");
92  elgg_log('Upgrade unlocked.', 'NOTICE');
93 }
elgg_get_upgrade_files($upgrade_path=null)
Returns a list of upgrade files relative to the $upgrade_path dir.
Definition: upgrade.php:52
delete_data($query, array $params=[])
Remove a row from the database.
Definition: database.php:116
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
Definition: elgglib.php:411
global $CONFIG
datalist_set($name, $value)
Set the value for a datalist element.
elgg global
Pointer to the global context.
Definition: elgglib.js:12
elgg_set_processed_upgrades(array $processed_upgrades)
Saves the processed upgrades to a dataset.
Definition: upgrade.php:20
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:1028
elgg_get_upgrade_file_version($filename)
Returns the version of the upgrade filename.
Definition: upgrade.php:33
$filename
elgg_get_engine_path()
/path/to/elgg/engine
_elgg_upgrade_unlock()
Unlocks upgrade.
Definition: upgrade.php:89