Fixing "password encrypted" method and "store session in db" during the upgrade command see BT#5572

skala
Julio Montoya 13 years ago
parent 2700a28c7e
commit 9721e68a43
  1. 13
      app/console-config.php
  2. 87
      app/console.php
  3. 21
      main/install/1.9.0/update-db-1.8.8-1.9.0.inc.php
  4. 11
      src/ChamiloLMS/Command/Database/UpgradeCommand.php

@ -9,7 +9,7 @@ use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Component\Yaml\Parser;
$sysPath = __DIR__."/../../";
$sysPath = __DIR__."../../";
AnnotationRegistry::registerFile($sysPath."vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
$reader = new AnnotationReader();
@ -36,11 +36,12 @@ if (is_file($configurationFile) && file_exists($configurationFile)) {
if (is_file($newConfigurationFile) && file_exists($newConfigurationFile)) {
$yaml = new Parser();
$_configurationYML = $yaml->parse(file_get_contents($newConfigurationFile));
if (isset($_configuration)) {
$_configuration = array_merge($_configuration, $_configurationYML);
} else {
$_configuration = $_configurationYML;
if (!empty($_configurationYML)) {
if (isset($_configuration)) {
$_configuration = array_merge($_configuration, $_configurationYML);
} else {
$_configuration = $_configurationYML;
}
}
}

@ -11,9 +11,8 @@ if (PHP_SAPI != 'cli') {
require_once dirname(__FILE__).'/../main/inc/global.inc.php';
// Variable $helperSet is defined inside cli-config.php
require __DIR__ . '/config/console-config.php';
require __DIR__.'/console-config.php';
//$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli = new \Symfony\Component\Console\Application('Chamilo CLI');
$cli->setCatchExceptions(true);
@ -23,50 +22,50 @@ foreach ($helpers as $name => $helper) {
}
$cli->addCommands(array(
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
// Migrations Commands
new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand(),
// Migrations Commands
new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand(),
//Chamilo commands
new ChamiloLMS\Command\Database\UpgradeCommand(),
new ChamiloLMS\Command\Database\InstallCommand(),
new ChamiloLMS\Command\Database\StatusCommand(),
new ChamiloLMS\Command\Database\SetupCommand(),
//Chamilo commands
new ChamiloLMS\Command\Database\UpgradeCommand(),
new ChamiloLMS\Command\Database\InstallCommand(),
new ChamiloLMS\Command\Database\StatusCommand(),
new ChamiloLMS\Command\Database\SetupCommand(),
//Chash commands
new Chash\Command\Database\RunSQLCommand(),
new Chash\Command\Database\DumpCommand(),
new Chash\Command\Database\RestoreCommand(),
new Chash\Command\Database\SQLCountCommand(),
new Chash\Command\Database\FullBackupCommand(),
new Chash\Command\Database\DropDatabaseCommand(),
new Chash\Command\Files\CleanTempFolderCommand(),
new Chash\Command\Files\CleanConfigFiles(),
new Chash\Command\Translation\ExportLanguageCommand(),
new Chash\Command\Translation\ImportLanguageCommand()
));
//Chash commands
new Chash\Command\Database\RunSQLCommand(),
new Chash\Command\Database\DumpCommand(),
new Chash\Command\Database\RestoreCommand(),
new Chash\Command\Database\SQLCountCommand(),
new Chash\Command\Database\FullBackupCommand(),
new Chash\Command\Database\DropDatabaseCommand(),
new Chash\Command\Files\CleanTempFolderCommand(),
new Chash\Command\Files\CleanConfigFiles(),
new Chash\Command\Translation\ExportLanguageCommand(),
new Chash\Command\Translation\ImportLanguageCommand()
));
$cli->run();

@ -11,6 +11,8 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
$mainConnection->beginTransaction();
$singleDbForm = $_configuration['single_database'];
$dbNameForm = $_configuration['main_database'];
$dbStatsForm = isset($_configuration['statistics_database']) ? $_configuration['statistics_database'] : $_configuration['main_database'];
@ -190,7 +192,10 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
$i++;
}
$output->writeln("Moving old tables into the new structure");
$output->writeln("Moving old course tables to the new structure 1 single database");
$progress = $this->getHelperSet()->get('progress');
$progress->start($output, count($list));
foreach ($list as $row_course) {
if (!$singleDbForm) {
@ -296,7 +301,8 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
'wiki_mailcue'
);
$output->writeln('<<<------- Loading DB course '.$row_course['db_name'].' -------->>');
$output->writeln('');
$output->writeln('Course DB'.$row_course['db_name']);
$old_count = 0;
foreach ($table_list as $table) {
@ -308,8 +314,6 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
$just_table_name = "$prefix{$row_course['db_name']}_".$table;
}
//$output->writeln('Loading table '.$old_table);
$course_id = $row_course['id'];
$new_table = DB_COURSE_PREFIX.$table;
@ -339,8 +343,6 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
$output->writeln("Count(*) in table $old_table failed");
}
//$output->writeln("$old_count rows found in $old_table ");
$sql = "SELECT * FROM $old_table";
$result = iDatabase::query($sql);
@ -359,7 +361,7 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
}
}
$output->writeln("$count/$old_count rows inserted in $new_table");
//$output->writeln("$count/$old_count rows inserted in $new_table");
if ($old_count != $count) {
$output->writeln("ERROR count of new and old table doesn't match: $old_count - $new_table");
@ -367,12 +369,15 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
$output->writeln(print_r($errors, 1));
}
} else {
$output->writeln('');
$output->writeln("Seems that the table $old_table doesn't exists ");
}
}
$output->writeln('<<<------- end -------->>');
$progress->advance();
}
$progress->finish();
$output->writeln("End course migration");

@ -479,13 +479,24 @@ class UpgradeCommand extends CommonCommand
*/
public function updateConfiguration($version)
{
global $userPasswordCrypted, $storeSessionInDb;
$_configuration = $this->getHelper('configuration')->getConfiguration();
$configurationPath = $this->getHelper('configuration')->getConfigurationPath();
$dumper = new Dumper();
$_configuration['system_version'] = $version;
if (!isset($_configuration['password_encryption'])) {
$_configuration['password_encryption'] = $userPasswordCrypted;
}
if (!isset($_configuration['session_stored_in_db'])) {
$_configuration['session_stored_in_db'] = $storeSessionInDb;
}
$yaml = $dumper->dump($_configuration, 2); //inline
$newConfigurationFile = $configurationPath.'configuration.yml';
file_put_contents($newConfigurationFile, $yaml);

Loading…
Cancel
Save