/**
* Update Piwik codebase by downloading and installing the latest version.
*
* @param bool $https Whether to use HTTPS if supported of not. If false, will use HTTP.
* @return string[] Return an array of messages for the user.
* @throws ArchiveDownloadException
* @throws UpdaterException
* @throws Exception
*/
public function updatePiwik($https = true)
{
if (!$this->isNewVersionAvailable()) {
throw new Exception($this->translator->translate('CoreUpdater_ExceptionAlreadyLatestVersion', Version::VERSION));
}
SettingsServer::setMaxExecutionTime(0);
$newVersion = $this->getLatestVersion();
$url = $this->getArchiveUrl($newVersion, $https);
$messages = array();
try {
$archiveFile = $this->downloadArchive($newVersion, $url);
$messages[] = $this->translator->translate('CoreUpdater_DownloadingUpdateFromX', $url);
$extractedArchiveDirectory = $this->decompressArchive($archiveFile);
$messages[] = $this->translator->translate('CoreUpdater_UnpackingTheUpdate');
$this->verifyDecompressedArchive($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_VerifyingUnpackedFiles');
$disabledPluginNames = $this->disableIncompatiblePlugins($newVersion);
if (!empty($disabledPluginNames)) {
$messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames));
}
$this->installNewFiles($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_InstallingTheLatestVersion');
} catch (ArchiveDownloadException $e) {
throw $e;
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
return $messages;
}