Skip to content
Extraits de code Groupes Projets
Valider f3a78c3a rédigé par mattab's avatar mattab
Parcourir les fichiers

Adding 2.0-a17 update file to delete old plugin folders

parent b0b8081d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -152,7 +152,7 @@ class Updater
* Update the named component
*
* @param string $componentName 'core', or plugin name
* @throws \Exception|Updater_UpdateErrorException
* @throws \Exception|UpdaterErrorException
* @return array of warning strings if applicable
*/
public function update($componentName)
......@@ -169,7 +169,7 @@ class Updater
}
self::recordComponentSuccessfullyUpdated($componentName, $fileVersion);
} catch (Updater_UpdateErrorException $e) {
} catch (UpdaterErrorException $e) {
throw $e;
} catch (\Exception $e) {
$warningMessages[] = $e->getMessage();
......@@ -286,7 +286,7 @@ class Updater
*
* @param string $file Update script filename
* @param array $sqlarray An array of SQL queries to be executed
* @throws Updater_UpdateErrorException
* @throws UpdaterErrorException
*/
static function updateDatabase($file, $sqlarray)
{
......@@ -298,7 +298,7 @@ class Updater
|| !Db::get()->isErrNo($e, $ignoreError)
) {
$message = $file . ":\nError trying to execute the query '" . $update . "'.\nThe error was: " . $e->getMessage();
throw new Updater_UpdateErrorException($message);
throw new UpdaterErrorException($message);
}
}
}
......@@ -311,6 +311,6 @@ class Updater
* @package Piwik
* @subpackage Updater
*/
class Updater_UpdateErrorException extends \Exception
class UpdaterErrorException extends \Exception
{
}
......@@ -44,7 +44,7 @@ class Updates_0_5_4 extends Updates
throw new \Exception('mandatory update failed');
}
} catch (\Exception $e) {
throw new \Piwik\Updater_UpdateErrorException("Please edit your config/config.ini.php file and add below <code>[superuser]</code> the following line: <br /><code>salt = $salt</code>");
throw new \Piwik\UpdaterErrorException("Please edit your config/config.ini.php file and add below <code>[superuser]</code> the following line: <br /><code>salt = $salt</code>");
}
}
......
......@@ -45,7 +45,7 @@ class Updates_0_6_3 extends Updates
throw new \Exception('mandatory update failed');
}
} catch (\Exception $e) {
throw new \Piwik\Updater_UpdateErrorException("Please edit your config/config.ini.php file and add below <code>[database]</code> the following line: <br /><code>schema = Myisam</code>");
throw new \Piwik\UpdaterErrorException("Please edit your config/config.ini.php file and add below <code>[database]</code> the following line: <br /><code>schema = Myisam</code>");
}
}
......
......@@ -55,17 +55,7 @@ class Updates_2_0_a13 extends Updates
Updater::updateDatabase(__FILE__, self::getSql());
// Deleting old plugins
$obsoleteDirectories = array(
PIWIK_INCLUDE_PATH . '/plugins/Referers',
PIWIK_INCLUDE_PATH . '/plugins/PDFReports',
);
foreach ($obsoleteDirectories as $dir) {
if (file_exists($dir)) {
Filesystem::unlinkRecursive($dir, true);
}
}
// old plugins deleted in 2.0-a17 update file
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('Referrers');
......
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik
* @package Piwik
*/
namespace Piwik\Updates;
use Piwik\Db;
use Piwik\Filesystem;
use Piwik\Updates;
/**
* @package Updates
*/
class Updates_2_0_a17 extends Updates
{
public static function update()
{
$errors = array();
// Deleting old plugins
$obsoleteDirectories = array(
PIWIK_INCLUDE_PATH . '/plugins/Referers',
PIWIK_INCLUDE_PATH . '/plugins/PDFReports',
);
foreach ($obsoleteDirectories as $dir) {
if (file_exists($dir)) {
Filesystem::unlinkRecursive($dir, true);
}
if (file_exists($dir)) {
$errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n";
}
}
if(!empty($errors)) {
throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors));
}
}
}
\ No newline at end of file
......@@ -24,5 +24,5 @@ final class Version
* Current Piwik version
* @var string
*/
const VERSION = '2.0-a14';
const VERSION = '2.0-a17';
}
......@@ -27,7 +27,7 @@ use Piwik\SettingsServer;
use Piwik\Unzip;
use Piwik\UpdateCheck;
use Piwik\Updater;
use Piwik\Updater_UpdateErrorException;
use Piwik\UpdaterErrorException;
use Piwik\Version;
use Piwik\View;
use Piwik\View\OneClickDone;
......@@ -119,6 +119,18 @@ class Controller extends \Piwik\Plugin\Controller
echo $view->render();
}
protected function redirectToDashboardWhenNoError($updater)
{
if (count($updater->getSqlQueriesToExecute()) == 1
&& !$this->coreError
&& empty($this->warningMessages)
&& empty($this->errorMessages)
&& empty($this->deactivatedPlugins)
) {
Piwik::redirectToModule('CoreHome');
}
}
private function checkNewVersionIsAvailableOrDie()
{
$newVersion = UpdateCheck::isNewestVersionAvailable();
......@@ -269,7 +281,6 @@ class Controller extends \Piwik\Plugin\Controller
$viewWelcome = new View($welcomeTemplate);
$viewDone = new View($doneTemplate);
$sqlQueries = $updater->getSqlQueriesToExecute();
if (Common::isPhpCliMode()) {
$this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile);
echo $viewWelcome->render();
......@@ -283,12 +294,11 @@ class Controller extends \Piwik\Plugin\Controller
$this->warningMessages = array();
$this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile);
if (count($sqlQueries) == 1 && !$this->coreError) {
Piwik::redirectToModule('CoreHome');
}
$this->redirectToDashboardWhenNoError($updater);
echo $viewDone->render();
} else {
$viewWelcome->queries = $sqlQueries;
$viewWelcome->queries = $updater->getSqlQueriesToExecute();
$viewWelcome->isMajor = $updater->hasMajorDbUpdate();
$this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile);
echo $viewWelcome->render();
......@@ -365,7 +375,7 @@ class Controller extends \Piwik\Plugin\Controller
foreach ($componentsWithUpdateFile as $name => $filenames) {
try {
$this->warningMessages = array_merge($this->warningMessages, $updater->update($name));
} catch (Updater_UpdateErrorException $e) {
} catch (UpdaterErrorException $e) {
$this->errorMessages[] = $e->getMessage();
if ($name == 'core') {
$this->coreError = true;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter