1.20.x updater.inc | public Updater::update(&$filetransfer, $overrides = array()) |
Updates a Backdrop project, returns a list of next actions.
Parameters
FileTransfer $filetransfer: Object that is a child of FileTransfer. Used for moving files to the server.
array $overrides: An array of settings to override defaults; see self::getInstallArgs().
Return value
array: An array of links which the user may need to complete the update
Throws
File
- includes/
updater.inc, line 269 - Classes used for updating various files in the Backdrop webroot. These classes use a FileTransfer object to actually perform the operations. Normally, the FileTransfer is provided when the site owner is redirected to authorize.php as part of a…
Class
- Updater
- Base class for Updaters used in Backdrop.
Code
public function update(&$filetransfer, $overrides = array()) {
try {
// Establish arguments with possible overrides.
$args = $this->getInstallArgs($overrides);
// Take a Backup.
if ($args['make_backup']) {
$this->makeBackup($filetransfer, $args['install_dir'], $args['backup_dir']);
}
if (!$this->name) {
// This is bad, don't want to delete the install directory.
throw new UpdaterException(t('Fatal error in update, cowardly refusing to wipe out the install directory.'));
}
// Make sure the installation parent directory exists and is writable.
$this->prepareInstallDirectory($filetransfer, $args['install_dir']);
// Note: If the project is installed in top-level, it will not be
// deleted. It will be installed in the root as that will override
// the top-level reference and not break other sites which are using it.
if (is_dir($args['install_dir'] . '/' . $this->name)) {
// Remove the existing installed file.
$filetransfer->removeDirectory($args['install_dir'] . '/' . $this->name);
}
// Copy the directory in place.
// Check for core udpate.
if ($this->name == 'backdrop') {
$source = $this->source . '/core';
$name = 'core';
}
else {
$source = $this->source;
$name = $this->name;
}
$filetransfer->copyDirectory($source, $args['install_dir']);
// Make sure what we just installed is readable by the web server.
$this->makeWorldReadable($filetransfer, $args['install_dir'] . '/' . $name);
// Run the updates.
// @TODO: decide if we want to implement this.
$this->postUpdate();
// For now, just return a list of links of things to do.
return $this->postUpdateTasks();
}
catch (FileTransferException $e) {
throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments))));
}
}