diff options
Diffstat (limited to 'core/Command/Maintenance')
-rw-r--r-- | core/Command/Maintenance/Install.php | 14 | ||||
-rw-r--r-- | core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php | 18 | ||||
-rw-r--r-- | core/Command/Maintenance/Mimetype/UpdateDB.php | 4 | ||||
-rw-r--r-- | core/Command/Maintenance/Mimetype/UpdateJS.php | 3 | ||||
-rw-r--r-- | core/Command/Maintenance/Repair.php | 4 | ||||
-rw-r--r-- | core/Command/Maintenance/UpdateHtaccess.php | 3 | ||||
-rw-r--r-- | core/Command/Maintenance/UpdateTheme.php | 1 |
7 files changed, 36 insertions, 11 deletions
diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index 31f6d1cd79d..6170c5a2638 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -15,6 +15,7 @@ use OC\Console\TimestampFormatter; use OC\Migration\ConsoleOutput; use OC\Setup; use OC\SystemConfig; +use OCP\Server; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; @@ -43,6 +44,7 @@ class Install extends Command { ->addOption('database-user', null, InputOption::VALUE_REQUIRED, 'Login to connect to the database') ->addOption('database-pass', null, InputOption::VALUE_OPTIONAL, 'Password of the database user', null) ->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null) + ->addOption('disable-admin-user', null, InputOption::VALUE_NONE, 'Disable the creation of an admin user') ->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'Login of the admin account', 'admin') ->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account') ->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'E-Mail of the admin account') @@ -51,15 +53,15 @@ class Install extends Command { protected function execute(InputInterface $input, OutputInterface $output): int { // validate the environment - $setupHelper = \OCP\Server::get(\OC\Setup::class); + $setupHelper = Server::get(Setup::class); $sysInfo = $setupHelper->getSystemInfo(true); $errors = $sysInfo['errors']; if (count($errors) > 0) { $this->printErrors($output, $errors); // ignore the OS X setup warning - if (count($errors) !== 1 || - (string)$errors[0]['error'] !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') { + if (count($errors) !== 1 + || (string)$errors[0]['error'] !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk!') { return 1; } } @@ -119,6 +121,7 @@ class Install extends Command { if ($input->hasParameterOption('--database-pass')) { $dbPass = (string)$input->getOption('database-pass'); } + $disableAdminUser = (bool)$input->getOption('disable-admin-user'); $adminLogin = $input->getOption('admin-user'); $adminPassword = $input->getOption('admin-pass'); $adminEmail = $input->getOption('admin-email'); @@ -141,7 +144,7 @@ class Install extends Command { } } - if (is_null($adminPassword)) { + if (!$disableAdminUser && $adminPassword === null) { /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $question = new Question('What is the password you like to use for the admin account <' . $adminLogin . '>?'); @@ -150,7 +153,7 @@ class Install extends Command { $adminPassword = $helper->ask($input, $output, $question); } - if ($adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) { + if (!$disableAdminUser && $adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) { throw new InvalidArgumentException('Invalid e-mail-address <' . $adminEmail . '> for <' . $adminLogin . '>.'); } @@ -160,6 +163,7 @@ class Install extends Command { 'dbpass' => $dbPass, 'dbname' => $dbName, 'dbhost' => $dbHost, + 'admindisable' => $disableAdminUser, 'adminlogin' => $adminLogin, 'adminpass' => $adminPassword, 'adminemail' => $adminEmail, diff --git a/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php b/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php index 283809a9031..f8f19a61993 100644 --- a/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php +++ b/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php @@ -15,9 +15,13 @@ class GenerateMimetypeFileBuilder { * @param array<string,string> $aliases * @return string */ - public function generateFile(array $aliases): string { + public function generateFile(array $aliases, array $names): string { // Remove comments $aliases = array_filter($aliases, static function ($key) { + // Single digit extensions will be treated as integers + // Let's make sure they are strings + // https://github.com/nextcloud/server/issues/42902 + $key = (string)$key; return !($key === '' || $key[0] === '_'); }, ARRAY_FILTER_USE_KEY); @@ -67,6 +71,15 @@ class GenerateMimetypeFileBuilder { sort($themes[$theme]); } + $namesOutput = ''; + foreach ($names as $key => $name) { + if (str_starts_with($key, '_') || trim($name) === '') { + // Skip internal names + continue; + } + $namesOutput .= "'$key': t('core', " . json_encode($name) . "),\n"; + } + //Generate the JS return '/** * This file is automatically generated @@ -79,7 +92,8 @@ class GenerateMimetypeFileBuilder { OC.MimeTypeList={ aliases: ' . json_encode($aliases, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . ', files: ' . json_encode($files, JSON_PRETTY_PRINT) . ', - themes: ' . json_encode($themes, JSON_PRETTY_PRINT) . ' + themes: ' . json_encode($themes, JSON_PRETTY_PRINT) . ', + names: {' . $namesOutput . '}, }; '; } diff --git a/core/Command/Maintenance/Mimetype/UpdateDB.php b/core/Command/Maintenance/Mimetype/UpdateDB.php index 9ba535ef658..4467e89eb32 100644 --- a/core/Command/Maintenance/Mimetype/UpdateDB.php +++ b/core/Command/Maintenance/Mimetype/UpdateDB.php @@ -45,6 +45,10 @@ class UpdateDB extends Command { $totalNewMimetypes = 0; foreach ($mappings as $ext => $mimetypes) { + // Single digit extensions will be treated as integers + // Let's make sure they are strings + // https://github.com/nextcloud/server/issues/42902 + $ext = (string)$ext; if ($ext[0] === '_') { // comment continue; diff --git a/core/Command/Maintenance/Mimetype/UpdateJS.php b/core/Command/Maintenance/Mimetype/UpdateJS.php index 35633f16355..2132ff54c6d 100644 --- a/core/Command/Maintenance/Mimetype/UpdateJS.php +++ b/core/Command/Maintenance/Mimetype/UpdateJS.php @@ -32,7 +32,8 @@ class UpdateJS extends Command { // Output the JS $generatedMimetypeFile = new GenerateMimetypeFileBuilder(); - file_put_contents(\OC::$SERVERROOT . '/core/js/mimetypelist.js', $generatedMimetypeFile->generateFile($aliases)); + $namings = $this->mimetypeDetector->getAllNamings(); + file_put_contents(\OC::$SERVERROOT . '/core/js/mimetypelist.js', $generatedMimetypeFile->generateFile($aliases, $namings)); $output->writeln('<info>mimetypelist.js is updated'); return 0; diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php index 09d75cec45c..f0c88f6811b 100644 --- a/core/Command/Maintenance/Repair.php +++ b/core/Command/Maintenance/Repair.php @@ -61,7 +61,7 @@ class Repair extends Command { $this->repair->addStep($step); } - $apps = $this->appManager->getInstalledApps(); + $apps = $this->appManager->getEnabledApps(); foreach ($apps as $app) { if (!$this->appManager->isEnabledForUser($app)) { continue; @@ -70,7 +70,7 @@ class Repair extends Command { if (!is_array($info)) { continue; } - \OC_App::loadApp($app); + $this->appManager->loadApp($app); $steps = $info['repair-steps']['post-migration']; foreach ($steps as $step) { try { diff --git a/core/Command/Maintenance/UpdateHtaccess.php b/core/Command/Maintenance/UpdateHtaccess.php index 4939e368e2d..eeff3bf8c62 100644 --- a/core/Command/Maintenance/UpdateHtaccess.php +++ b/core/Command/Maintenance/UpdateHtaccess.php @@ -7,6 +7,7 @@ */ namespace OC\Core\Command\Maintenance; +use OC\Setup; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -19,7 +20,7 @@ class UpdateHtaccess extends Command { } protected function execute(InputInterface $input, OutputInterface $output): int { - if (\OC\Setup::updateHtaccess()) { + if (Setup::updateHtaccess()) { $output->writeln('.htaccess has been updated'); return 0; } else { diff --git a/core/Command/Maintenance/UpdateTheme.php b/core/Command/Maintenance/UpdateTheme.php index f819b9c8e58..3fbcb546cca 100644 --- a/core/Command/Maintenance/UpdateTheme.php +++ b/core/Command/Maintenance/UpdateTheme.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later |