Fix migration see BT#11447

- Use rename instead of custom "move" function
- Delete c_item_property from deleted sessions, users, groups to avoid conflicts
1.10.x
jmontoyaa 10 years ago
parent 6c5445b27b
commit d542df949b
  1. 15
      app/Migrations/Schema/V110/Version20150603181728.php
  2. 17
      main/install/install.lib.php
  3. 13
      main/install/update-files-1.9.0-1.10.0.inc.php

@ -49,14 +49,17 @@ class Version20150603181728 extends AbstractMigrationChamilo
MODIFY session_id INT DEFAULT NULL,
MODIFY to_user_id INT NULL
');
$this->addSql("UPDATE c_item_property SET session_id = NULL WHERE session_id NOT IN (SELECT id FROM session)");
$this->addSql("UPDATE c_item_property SET to_group_id = NULL WHERE to_group_id NOT IN (SELECT iid FROM c_group_info)");
$this->addSql("UPDATE c_item_property SET to_user_id = NULL WHERE to_user_id NOT IN (SELECT user_id FROM user)");
$this->addSql("UPDATE c_item_property SET start_visible = NULL WHERE start_visible = '0000-00-00 00:00:00'");
$this->addSql("UPDATE c_item_property SET end_visible = NULL WHERE end_visible = '0000-00-00 00:00:00'");
$this->addSql("UPDATE c_item_property SET to_user_id = NULL WHERE to_user_id NOT IN (SELECT id FROM user)");
$this->addSql("UPDATE c_item_property SET insert_user_id = NULL WHERE insert_user_id NOT IN (SELECT id FROM user)");
$this->addSql("UPDATE c_item_property SET session_id = NULL WHERE session_id NOT IN (SELECT id FROM session)");
// Remove inconsistencies about non-existing courses
$this->addSql("DELETE FROM c_item_property WHERE session_id IS NOT NULL and session_id <> 0 AND session_id NOT IN (SELECT id FROM session)");
$this->addSql("DELETE FROM c_item_property WHERE to_group_id IS NOT NULL AND to_group_id <> 0 AND to_group_id NOT IN (SELECT iid FROM c_group_info)");
$this->addSql("DELETE FROM c_item_property WHERE to_user_id IS NOT NULL and to_user_id <> 0 AND to_user_id NOT IN (SELECT user_id FROM user)");
$this->addSql("DELETE FROM c_item_property WHERE to_user_id IS NOT NULL AND to_user_id <> 0 AND to_user_id NOT IN (SELECT id FROM user)");
$this->addSql("DELETE FROM c_item_property WHERE insert_user_id IS NOT NULL AND insert_user_id <> 0 AND insert_user_id NOT IN (SELECT id FROM user)");
// Remove inconsistencies about non-existing courses
$this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)");

@ -303,23 +303,6 @@ function set_file_folder_permissions()
@chmod('..', 0755); //set permissions on parent dir of install dir
}
/**
* Add's a .htaccess file to the courses directory
* @param string $url_append The path from your webroot to your chamilo root
* @return bool Result of writing the file
*/
/*function write_courses_htaccess_file($url_append)
{
$content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
$content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content);
$fp = @fopen(api_get_path(SYS_COURSE_PATH).'.htaccess', 'w');
if ($fp) {
fwrite($fp, $content);
return fclose($fp);
}
return false;
}*/
/**
* Write the main system config file
* @param string $path Path to the config file

@ -184,14 +184,20 @@ if (defined('SYSTEM_INSTALLATION')) {
error_log('Moving folders');
}
$fs = new Filesystem();
foreach ($movePathList as $origin => $destination) {
if (is_dir($origin)) {
move($origin, $destination, true, true);
$fs->rename($origin, $destination);
if ($debug) {
error_log("Renaming: '$origin' to '$destination'");
}
//move($origin, $destination, true, true);
}
}
// Delete all "courses/ABC/index.php" files.
if ($debug) {
error_log('Deleting old courses/ABC/index.php files');
}
@ -200,12 +206,11 @@ if (defined('SYSTEM_INSTALLATION')) {
$courseDir = api_get_path(SYS_APP_PATH).'courses';
if (is_dir($courseDir)) {
$dirs = $finder->directories()->in($courseDir);
$fs = new Filesystem();
/** @var Symfony\Component\Finder\SplFileInfo $dir */
foreach ($dirs as $dir) {
$indexFile = $dir->getPath().'/index.php';
if ($debug) {
error_log('Deleting '.$indexFile);
error_log('Deleting: '.$indexFile);
}
if ($fs->exists($indexFile)) {
$fs->remove($indexFile);

Loading…
Cancel
Save