21 public function run() {
68 if (!$processed_upgrades) {
77 if ($upgrade_files ===
false) {
94 if (!@self::includeCode(
"$upgrade_path/$upgrade")) {
96 error_log(
"Could not include $upgrade_path/$upgrade");
98 }
catch (Exception
$e) {
100 error_log($e->getMessage());
103 if (!self::includeCode(
"$upgrade_path/$upgrade")) {
105 error_log(
"Could not include $upgrade_path/$upgrade");
136 return include $file;
148 $processed_upgrades[] = $upgrade;
149 $processed_upgrades = array_unique($processed_upgrades);
150 return datalist_set(
'processed_upgrades', serialize($processed_upgrades));
161 return $unserialized;
172 preg_match(
'/^([0-9]{10})([\.a-z0-9-_]+)?\.(php)$/i',
$filename, $matches);
174 if (isset($matches[1])) {
175 return (
int) $matches[1];
188 if (!$upgrade_path) {
192 $handle = opendir($upgrade_path);
198 $upgrade_files = array();
200 while ($upgrade_file = readdir($handle)) {
202 if (is_dir($upgrade_path .
'$upgrade_file')) {
206 if (!$upgrade_version) {
209 $upgrade_files[] = $upgrade_file;
212 sort($upgrade_files);
214 return $upgrade_files;
226 if ($upgrade_files === null) {
230 if ($processed_upgrades === null) {
231 $processed_upgrades = unserialize(
datalist_get(
'processed_upgrades'));
232 if (!is_array($processed_upgrades)) {
233 $processed_upgrades = array();
237 $unprocessed = array_diff($upgrade_files, $processed_upgrades);
253 $quiet = !$dbversion;
256 if ($this->
dbUpgrade($dbversion,
'', $quiet)) {
264 $upgrade_details =
new stdClass;
265 $upgrade_details->from = $dbversion;
289 $upgrades_18 = array(
299 $processed_upgrades = array();
301 foreach ($upgrade_files as $upgrade_file) {
303 if (in_array($upgrade_file, $upgrades_18) || !preg_match(
"/[0-9]{10}\.php/", $upgrade_file)) {
310 if ($upgrade_version < $db_version) {
326 insert_data(
"create table {$CONFIG->dbprefix}upgrade_lock (id INT)");
327 elgg_log(
'Locked for upgrade.',
'NOTICE');
331 elgg_log(
'Cannot lock for upgrade: already locked.',
'WARNING');
342 delete_data(
"drop table {$CONFIG->dbprefix}upgrade_lock");
343 elgg_log(
'Upgrade unlocked.',
'NOTICE');
387 $fromdir = $CONFIG->path .
'engine/schema/upgrades/';
392 if ($handle = opendir($fromdir)) {
393 $sqlupgrades = array();
395 while ($sqlfile = readdir($handle)) {
396 if (!is_dir($fromdir . $sqlfile)) {
397 if (preg_match(
'/^([0-9]{10})\.(sql)$/', $sqlfile, $matches)) {
398 $sql_version = (int) $matches[1];
400 $sqlupgrades[] = $sqlfile;
408 if (
sizeof($sqlupgrades) > 0) {
409 foreach ($sqlupgrades as $sqlfile) {
416 error_log($e->getmessage());
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
bootstrap17to18()
Boot straps into 1.8 upgrade system from 1.7.
elgg_reset_system_cache()
Reset the system cache by deleting the caches.
elgg_invalidate_simplecache()
Deletes all cached views in the simplecache and sets the lastcache and lastupdate time to 0 for every...
upgradeCode($version, $quiet=false)
Run any php upgrade scripts which are required.
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
setProcessedUpgrade($upgrade)
Saves a processed upgrade to a dataset.
$upgrades
Lists pending upgrades.
delete_data($query)
Remove a row from the database.
getUnprocessedUpgrades($upgrade_files=null, $processed_upgrades=null)
Checks if any upgrades need to be run.
static includeCode($file)
PHP include a file with a very limited scope.
getUpgradeMutex()
Creates a table {prefix}upgrade_lock that is used as a mutex for upgrades.
getUpgradeFiles($upgrade_path=null)
Returns a list of upgrade files relative to the $upgrade_path dir.
releaseUpgradeMutex()
Unlocks upgrade.
insert_data($query)
Insert a row into the database.
processUpgrades()
Upgrades Elgg Database and code.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
getUpgradeFileVersion($filename)
Returns the version of the upgrade filename.
datalist_get($name)
Get the value of a datalist element.
datalist_set($name, $value)
Set the value for a datalist element.
getProcessedUpgrades()
Gets a list of processes upgrades.
isUpgradeLocked()
Checks if upgrade is locked.
elgg global
Pointer to the global context.
dbUpgrade($version, $fromdir="", $quiet=false)
NOTE: If this is ever removed from Elgg, sites lose the ability to upgrade from 1.7.x and earlier to the latest version of Elgg without upgrading to 1.8 first.
run()
Run the upgrade process.
elgg system_message
Wrapper function for system_messages.
elgg_log($message, $level= 'NOTICE')
Display or log a message.
run_sql_script($scriptlocation)
Runs a full database script from disk.
get_data($query, $callback="")
Retrieve rows from the database.
elgg_get_version($human_readable=false)
Get the current Elgg version information.
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
elgg_unregister_event_handler($event, $object_type, $callback)
Unregisters a callback for an event.