/** * start migration * * @return array */ public function startMigration() { // allow as long execution on the web server as possible set_time_limit(0); try { $migration = new Migration($this->config, $this->view, $this->connection); $migration->reorganizeSystemFolderStructure(); $migration->updateDB(); foreach ($this->userManager->getBackends() as $backend) { $limit = 500; $offset = 0; do { $users = $backend->getUsers('', $limit, $offset); foreach ($users as $user) { $migration->reorganizeFolderStructureForUser($user); } $offset += $limit; } while (count($users) >= $limit); } $migration->finalCleanUp(); } catch (\Exception $e) { return array('data' => array('message' => (string) $this->l10n->t('A problem occurred, please check your log files (Error: %s)', [$e->getMessage()])), 'status' => 'error'); } return array('data' => array('message' => (string) $this->l10n->t('Migration Completed')), 'status' => 'success'); }
protected function execute(InputInterface $input, OutputInterface $output) { // perform system reorganization $migration = new Migration($this->config, $this->view, $this->connection, $this->logger); $users = $input->getArgument('user_id'); if (!empty($users)) { foreach ($users as $user) { if ($this->userManager->userExists($user)) { $output->writeln("Migrating keys <info>{$user}</info>"); $migration->reorganizeFolderStructureForUser($user); } else { $output->writeln("<error>Unknown user {$user}</error>"); } } } else { $output->writeln("Reorganize system folder structure"); $migration->reorganizeSystemFolderStructure(); $migration->updateDB(); foreach ($this->userManager->getBackends() as $backend) { $name = get_class($backend); if ($backend instanceof IUserBackend) { $name = $backend->getBackendName(); } $output->writeln("Migrating keys for users on backend <info>{$name}</info>"); $limit = 500; $offset = 0; do { $users = $backend->getUsers('', $limit, $offset); foreach ($users as $user) { $output->writeln(" <info>{$user}</info>"); $migration->reorganizeFolderStructureForUser($user); } $offset += $limit; } while (count($users) >= $limit); } } $migration->finalCleanUp(); }