summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/appinfo/remote.php2
-rw-r--r--apps/files_sharing/lib/controllers/sharecontroller.php7
-rw-r--r--apps/files_sharing/publicwebdav.php2
-rw-r--r--apps/files_sharing/tests/controller/sharecontroller.php5
-rwxr-xr-xautotest-external.sh70
-rwxr-xr-xautotest-hhvm.sh76
-rwxr-xr-xautotest.sh81
-rw-r--r--config/config.sample.php1
-rw-r--r--core/ajax/update.php6
-rw-r--r--core/command/app/listapps.php5
-rw-r--r--core/command/maintenance/install.php59
-rw-r--r--core/command/maintenance/repair.php3
-rw-r--r--core/command/upgrade.php6
-rw-r--r--core/setup/controller.php121
-rw-r--r--lib/base.php5
-rw-r--r--lib/private/connector/sabre/exceptionloggerplugin.php36
-rw-r--r--lib/private/files/view.php2
-rw-r--r--lib/private/installer.php13
-rw-r--r--lib/private/preview.php3
-rw-r--r--lib/private/preview/font.php19
-rw-r--r--lib/private/repair/repairlegacystorages.php136
-rw-r--r--lib/private/setup.php117
-rw-r--r--lib/private/share/helper.php30
-rw-r--r--lib/private/share/share.php2
-rw-r--r--lib/private/updater.php16
-rw-r--r--lib/private/util.php4
-rw-r--r--settings/js/apps.js6
-rw-r--r--tests/lib/connector/sabre/exceptionloggerplugin.php71
-rw-r--r--tests/lib/connector/sabre/file.php3
-rw-r--r--tests/lib/repair/repairlegacystorage.php21
-rw-r--r--tests/lib/setup.php17
-rw-r--r--tests/lib/share/helper.php51
32 files changed, 552 insertions, 444 deletions
diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php
index f631e47b5f6..e260f85fdb0 100644
--- a/apps/files/appinfo/remote.php
+++ b/apps/files/appinfo/remote.php
@@ -40,7 +40,7 @@ $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()
$server->addPlugin(new \OC\Connector\Sabre\DummyGetResponsePlugin());
$server->addPlugin(new \OC\Connector\Sabre\FilesPlugin($objectTree));
$server->addPlugin(new \OC\Connector\Sabre\MaintenancePlugin());
-$server->addPlugin(new \OC\Connector\Sabre\ExceptionLoggerPlugin('webdav'));
+$server->addPlugin(new \OC\Connector\Sabre\ExceptionLoggerPlugin('webdav', \OC::$server->getLogger()));
// wait with registering these until auth is handled and the filesystem is setup
$server->on('beforeMethod', function () use ($server, $objectTree) {
diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php
index 2e23ac5908e..ebc54265bf0 100644
--- a/apps/files_sharing/lib/controllers/sharecontroller.php
+++ b/apps/files_sharing/lib/controllers/sharecontroller.php
@@ -203,7 +203,12 @@ class ShareController extends Controller {
$shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', array('token' => $token));
$shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
- return new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
+ $csp = new OCP\AppFramework\Http\ContentSecurityPolicy();
+ $csp->addAllowedFrameDomain('\'self\'');
+ $response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
+ $response->setContentSecurityPolicy($csp);
+
+ return $response;
}
/**
diff --git a/apps/files_sharing/publicwebdav.php b/apps/files_sharing/publicwebdav.php
index 150f05a862a..c7ee950532e 100644
--- a/apps/files_sharing/publicwebdav.php
+++ b/apps/files_sharing/publicwebdav.php
@@ -33,7 +33,7 @@ $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()
$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload
$server->addPlugin(new \OC\Connector\Sabre\FilesPlugin($objectTree));
$server->addPlugin(new \OC\Connector\Sabre\MaintenancePlugin());
-$server->addPlugin(new \OC\Connector\Sabre\ExceptionLoggerPlugin('webdav'));
+$server->addPlugin(new \OC\Connector\Sabre\ExceptionLoggerPlugin('webdav', \OC::$server->getLogger()));
// wait with registering these until auth is handled and the filesystem is setup
$server->on('beforeMethod', function () use ($server, $objectTree, $authBackend) {
diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php
index 173f606e188..81e60b03cdc 100644
--- a/apps/files_sharing/tests/controller/sharecontroller.php
+++ b/apps/files_sharing/tests/controller/sharecontroller.php
@@ -159,7 +159,12 @@ class ShareControllerTest extends \Test\TestCase {
'nonHumanFileSize' => 33,
'maxSizeAnimateGif' => 10,
);
+
+ $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
+ $csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new TemplateResponse($this->container['AppName'], 'public', $sharedTmplParams, 'base');
+ $expectedResponse->setContentSecurityPolicy($csp);
+
$this->assertEquals($expectedResponse, $response);
}
diff --git a/autotest-external.sh b/autotest-external.sh
index 8254defc9ca..c4d5ffb181f 100755
--- a/autotest-external.sh
+++ b/autotest-external.sh
@@ -4,7 +4,7 @@
#
# @author Thomas Müller
# @author Morris Jobke
-# @copyright 2012, 2013 Thomas Müller thomas.mueller@tmit.eu
+# @copyright 2012-2015 Thomas Müller thomas.mueller@tmit.eu
# @copyright 2014 Morris Jobke hey@morrisjobke.de
#
@@ -90,67 +90,6 @@ fi
echo "Using database $DATABASENAME"
-# create autoconfig for sqlite, mysql and postgresql
-cat > ./tests/autoconfig-sqlite.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'sqlite',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
-);
-DELIM
-
-cat > ./tests/autoconfig-mysql.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'mysql',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASEUSER',
- 'dbname' => '$DATABASENAME',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
-cat > ./tests/autoconfig-pgsql.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'pgsql',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASEUSER',
- 'dbname' => '$DATABASENAME',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
-cat > ./tests/autoconfig-oci.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'oci',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASENAME',
- 'dbname' => 'XE',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
function execute_tests {
echo "Setup environment for $1 testing ..."
# back to root folder
@@ -197,15 +136,16 @@ EOF
to $DATABASENAME;
exit;
EOF
+ DATABASEUSER=$DATABASENAME
+ DATABASENAME='XE'
fi
# copy autoconfig
cp "$BASEDIR/tests/autoconfig-$1.php" "$BASEDIR/config/autoconfig.php"
# trigger installation
- echo "INDEX"
- php -f index.php | grep -i -C9999 error && echo "Error during setup" && exit 101
- echo "END INDEX"
+ echo "Installing ...."
+ ./occ maintenance:install --database=$1 --database-name=$DATABASENAME --database-host=localhost --database-user=$DATABASEUSER --database-pass=owncloud --database-table-prefix=oc_ --admin-user=$ADMINLOGIN --admin-pass=admin --data-dir=$DATADIR
#test execution
echo "Testing with $1 ..."
diff --git a/autotest-hhvm.sh b/autotest-hhvm.sh
index bf96a5133a6..7a8452c7f06 100755
--- a/autotest-hhvm.sh
+++ b/autotest-hhvm.sh
@@ -2,8 +2,14 @@
#
# ownCloud
#
+# @author Vincent Petry
+# @author Morris Jobke
+# @author Robin McCorkell
# @author Thomas Müller
-# @copyright 2012, 2013 Thomas Müller thomas.mueller@tmit.eu
+# @author Andreas Fischer
+# @author Joas Schilling
+# @author Lukas Reschke
+# @copyright 2012-2015 Thomas Müller thomas.mueller@tmit.eu
#
set -e
@@ -95,67 +101,6 @@ fi
echo "Using database $DATABASENAME"
-# create autoconfig for sqlite, mysql and postgresql
-cat > ./tests/autoconfig-sqlite.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'sqlite',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
-);
-DELIM
-
-cat > ./tests/autoconfig-mysql.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'mysql',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASEUSER',
- 'dbname' => '$DATABASENAME',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
-cat > ./tests/autoconfig-pgsql.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'pgsql',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASEUSER',
- 'dbname' => '$DATABASENAME',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
-cat > ./tests/autoconfig-oci.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'oci',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASENAME',
- 'dbname' => 'XE',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
function execute_tests {
echo "Setup environment for $1 testing ..."
# back to root folder
@@ -202,15 +147,16 @@ EOF
to $DATABASENAME;
exit;
EOF
+ DATABASEUSER=$DATABASENAME
+ DATABASENAME='XE'
fi
# copy autoconfig
cp "$BASEDIR/tests/autoconfig-$1.php" "$BASEDIR/config/autoconfig.php"
# trigger installation
- echo "INDEX"
- hhvm -f index.php | grep -i -C9999 error && echo "Error during setup" && exit 101
- echo "END INDEX"
+ echo "Installing ...."
+ hhvm ./occ maintenance:install --database=$1 --database-name=$DATABASENAME --database-host=localhost --database-user=$DATABASEUSER --database-pass=owncloud --database-table-prefix=oc_ --admin-user=$ADMINLOGIN --admin-pass=admin --data-dir=$DATADIR
#test execution
echo "Testing with $1 ..."
diff --git a/autotest.sh b/autotest.sh
index 647012ea618..94d63173547 100755
--- a/autotest.sh
+++ b/autotest.sh
@@ -2,8 +2,14 @@
#
# ownCloud
#
+# @author Vincent Petry
+# @author Morris Jobke
+# @author Robin McCorkell
# @author Thomas Müller
-# @copyright 2012, 2013 Thomas Müller thomas.mueller@tmit.eu
+# @author Andreas Fischer
+# @author Joas Schilling
+# @author Lukas Reschke
+# @copyright 2012-2015 Thomas Müller thomas.mueller@tmit.eu
#
set -e
@@ -89,67 +95,6 @@ fi
echo "Using database $DATABASENAME"
-# create autoconfig for sqlite, mysql and postgresql
-cat > ./tests/autoconfig-sqlite.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'sqlite',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
-);
-DELIM
-
-cat > ./tests/autoconfig-mysql.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'mysql',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASEUSER',
- 'dbname' => '$DATABASENAME',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
-cat > ./tests/autoconfig-pgsql.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'pgsql',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASEUSER',
- 'dbname' => '$DATABASENAME',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
-cat > ./tests/autoconfig-oci.php <<DELIM
-<?php
-\$AUTOCONFIG = array (
- 'installed' => false,
- 'dbtype' => 'oci',
- 'dbtableprefix' => 'oc_',
- 'adminlogin' => '$ADMINLOGIN',
- 'adminpass' => 'admin',
- 'directory' => '$DATADIR',
- 'dbuser' => '$DATABASENAME',
- 'dbname' => 'XE',
- 'dbhost' => 'localhost',
- 'dbpass' => 'owncloud',
-);
-DELIM
-
function execute_tests {
echo "Setup environment for $1 testing ..."
# back to root folder
@@ -162,8 +107,6 @@ function execute_tests {
rm -rf "$DATADIR"
mkdir "$DATADIR"
- # remove the old config file
- #rm -rf config/config.php
cp tests/preseed-config.php config/config.php
# drop database
@@ -196,15 +139,13 @@ EOF
to $DATABASENAME;
exit;
EOF
+ DATABASEUSER=$DATABASENAME
+ DATABASENAME='XE'
fi
- # copy autoconfig
- cp "$BASEDIR/tests/autoconfig-$1.php" "$BASEDIR/config/autoconfig.php"
-
# trigger installation
- echo "INDEX"
- php -f index.php | grep -i -C9999 error && echo "Error during setup" && exit 101
- echo "END INDEX"
+ echo "Installing ...."
+ ./occ maintenance:install --database=$1 --database-name=$DATABASENAME --database-host=localhost --database-user=$DATABASEUSER --database-pass=owncloud --database-table-prefix=oc_ --admin-user=$ADMINLOGIN --admin-pass=admin --data-dir=$DATADIR
#test execution
echo "Testing with $1 ..."
diff --git a/config/config.sample.php b/config/config.sample.php
index 94284e28dd8..8d8fed7ad8c 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -681,6 +681,7 @@ $CONFIG = array(
* - OC\Preview\StarOffice
* - OC\Preview\SVG
* - OC\Preview\TIFF
+ * - OC\Preview\Font
*
* .. note:: Troubleshooting steps for the MS Word previews are available
* at the :doc:`../configuration_files/collaborative_documents_configuration`
diff --git a/core/ajax/update.php b/core/ajax/update.php
index a9ab7316270..6d2dccfac7d 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -37,6 +37,12 @@ if (OC::checkUpgrade(false)) {
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
});
+ $updater->listen('\OC\Updater', 'repairWarning', function ($description) use ($eventSource, $l) {
+ $eventSource->send('notice', (string)$l->t('Repair warning: ') . $description);
+ });
+ $updater->listen('\OC\Updater', 'repairError', function ($description) use ($eventSource, $l) {
+ $eventSource->send('notice', (string)$l->t('Repair error: ') . $description);
+ });
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
$incompatibleApps[]= $app;
});
diff --git a/core/command/app/listapps.php b/core/command/app/listapps.php
index dc471c5453a..e957c15547a 100644
--- a/core/command/app/listapps.php
+++ b/core/command/app/listapps.php
@@ -23,6 +23,7 @@ class ListApps extends Command {
$apps = \OC_App::getAllApps();
$enabledApps = array();
$disabledApps = array();
+ $versions = \OC_App::getAppVersions();
//sort enabled apps above disabled apps
foreach ($apps as $app) {
@@ -37,11 +38,11 @@ class ListApps extends Command {
sort($disabledApps);
$output->writeln('Enabled:');
foreach ($enabledApps as $app) {
- $output->writeln(' - ' . $app);
+ $output->writeln(' - ' . $app . (isset($versions[$app]) ? ' (' . $versions[$app] . ')' : ''));
}
$output->writeln('Disabled:');
foreach ($disabledApps as $app) {
- $output->writeln(' - ' . $app);
+ $output->writeln(' - ' . $app . (isset($versions[$app]) ? ' (' . $versions[$app] . ')' : ''));
}
}
}
diff --git a/core/command/maintenance/install.php b/core/command/maintenance/install.php
index 0b01afc20ed..e92a546daac 100644
--- a/core/command/maintenance/install.php
+++ b/core/command/maintenance/install.php
@@ -3,6 +3,7 @@
namespace OC\Core\Command\Maintenance;
use InvalidArgumentException;
+use OC\Setup;
use OCP\IConfig;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -38,39 +39,36 @@ class Install extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
- $options = $this->validateInput($input, $output);
-
- $errors = \OC\Setup::install($options);
- if (count($errors) === 0) {
- $output->writeln("ownCloud was successfully installed");
- return 0;
- }
- foreach($errors as $error) {
- if (is_array($error)) {
- $output->writeln('<error>' . (string)$error['error'] . '</error>');
- $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>');
- } else {
- $output->writeln('<error>' . (string)$error . '</error>');
- }
+ // validate the environment
+ $setupHelper = new Setup($this->config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults());
+ $sysInfo = $setupHelper->getSystemInfo();
+ $errors = $sysInfo['errors'];
+ if (count($errors) > 0) {
+ $this->printErrors($output, $errors);
+ return 1;
}
- return 1;
+ // validate user input
+ $options = $this->validateInput($input, $output, array_keys($sysInfo['databases']));
+
+ // perform installation
+ $errors = $setupHelper->install($options);
+ if (count($errors) > 0) {
+ $this->printErrors($output, $errors);
+ return 1;
+ }
+ $output->writeln("ownCloud was successfully installed");
+ return 0;
}
/**
* @param InputInterface $input
* @param OutputInterface $output
+ * @param string[] $supportedDatabases
* @return array
*/
- protected function validateInput(InputInterface $input, OutputInterface $output) {
+ protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) {
$db = strtolower($input->getOption('database'));
- $supportedDatabases = $this->config->getSystemValue('supportedDatabases', [
- 'sqlite',
- 'mysql',
- 'pgsql',
- 'oci',
- 'mssql'
- ]);
if (!in_array($db, $supportedDatabases)) {
throw new InvalidArgumentException("Database <$db> is not supported.");
@@ -126,4 +124,19 @@ class Install extends Command {
];
return $options;
}
+
+ /**
+ * @param OutputInterface $output
+ * @param $errors
+ */
+ protected function printErrors(OutputInterface $output, $errors) {
+ foreach ($errors as $error) {
+ if (is_array($error)) {
+ $output->writeln('<error>' . (string)$error['error'] . '</error>');
+ $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>');
+ } else {
+ $output->writeln('<error>' . (string)$error . '</error>');
+ }
+ }
+ }
}
diff --git a/core/command/maintenance/repair.php b/core/command/maintenance/repair.php
index bf94b2647ce..bf2cac32ff9 100644
--- a/core/command/maintenance/repair.php
+++ b/core/command/maintenance/repair.php
@@ -46,6 +46,9 @@ class Repair extends Command {
$this->repair->listen('\OC\Repair', 'info', function ($description) use ($output) {
$output->writeln(' - ' . $description);
});
+ $this->repair->listen('\OC\Repair', 'warning', function ($description) use ($output) {
+ $output->writeln(' - WARNING: ' . $description);
+ });
$this->repair->listen('\OC\Repair', 'error', function ($description) use ($output) {
$output->writeln(' - ERROR: ' . $description);
});
diff --git a/core/command/upgrade.php b/core/command/upgrade.php
index e5402796136..8c3fbacb3f4 100644
--- a/core/command/upgrade.php
+++ b/core/command/upgrade.php
@@ -113,6 +113,12 @@ class Upgrade extends Command {
$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use($output) {
$output->writeln('<info>Disabled 3rd-party app: ' . $app . '</info>');
});
+ $updater->listen('\OC\Updater', 'repairWarning', function ($app) use($output) {
+ $output->writeln('<error>Repair warning: ' . $app . '</error>');
+ });
+ $updater->listen('\OC\Updater', 'repairError', function ($app) use($output) {
+ $output->writeln('<error>Repair error: ' . $app . '</error>');
+ });
$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
$output->writeln('<info>Checked database schema update for apps</info>');
});
diff --git a/core/setup/controller.php b/core/setup/controller.php
index cc7f4a3a985..fa3637dd8fd 100644
--- a/core/setup/controller.php
+++ b/core/setup/controller.php
@@ -9,42 +9,20 @@
namespace OC\Core\Setup;
-use bantu\IniGetWrapper\IniGetWrapper;
-use OCP\IConfig;
-use OCP\IL10N;
+use OC\Setup;
class Controller {
- /**
- * @var \OCP\IConfig
- */
- protected $config;
- /** @var IniGetWrapper */
- protected $iniWrapper;
- /** @var IL10N */
- protected $l10n;
- /** @var \OC_Defaults */
- protected $defaults;
-
- /**
- * @var string
- */
+ /** @var Setup */
+ protected $setupHelper;
+ /** @var string */
private $autoConfigFile;
/**
- * @param IConfig $config
- * @param IniGetWrapper $iniWrapper
- * @param IL10N $l10n
- * @param \OC_Defaults $defaults
+ * @param Setup $setupHelper
*/
- function __construct(IConfig $config,
- IniGetWrapper $iniWrapper,
- IL10N $l10n,
- \OC_Defaults $defaults) {
+ function __construct(Setup $setupHelper) {
$this->autoConfigFile = \OC::$SERVERROOT.'/config/autoconfig.php';
- $this->config = $config;
- $this->iniWrapper = $iniWrapper;
- $this->l10n = $l10n;
- $this->defaults = $defaults;
+ $this->setupHelper = $setupHelper;
}
/**
@@ -53,7 +31,7 @@ class Controller {
public function run($post) {
// Check for autosetup:
$post = $this->loadAutoConfig($post);
- $opts = $this->getSystemInfo();
+ $opts = $this->setupHelper->getSystemInfo();
// convert 'abcpassword' to 'abcpass'
if (isset($post['adminpassword'])) {
@@ -65,7 +43,7 @@ class Controller {
if(isset($post['install']) AND $post['install']=='true') {
// We have to launch the installation process :
- $e = \OC\Setup::install($post);
+ $e = $this->setupHelper->install($post);
$errors = array('errors' => $e);
if(count($e) > 0) {
@@ -126,85 +104,4 @@ class Controller {
return $post;
}
-
- /**
- * Gathers system information like database type and does
- * a few system checks.
- *
- * @return array of system info, including an "errors" value
- * in case of errors/warnings
- */
- public function getSystemInfo() {
- $setup = new \OC\Setup($this->config);
- $databases = $setup->getSupportedDatabases();
-
- $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
-
- $errors = array();
-
- // Create data directory to test whether the .htaccess works
- // Notice that this is not necessarily the same data directory as the one
- // that will effectively be used.
- @mkdir($dataDir);
- $htAccessWorking = true;
- if (is_dir($dataDir) && is_writable($dataDir)) {
- // Protect data directory here, so we can test if the protection is working
- \OC\Setup::protectDataDirectory();
-
- try {
- $htAccessWorking = \OC_Util::isHtaccessWorking();
- } catch (\OC\HintException $e) {
- $errors[] = array(
- 'error' => $e->getMessage(),
- 'hint' => $e->getHint()
- );
- $htAccessWorking = false;
- }
- }
-
-
- if (\OC_Util::runningOnMac()) {
- $errors[] = array(
- 'error' => $this->l10n->t(
- 'Mac OS X is not supported and %s will not work properly on this platform. ' .
- 'Use it at your own risk! ',
- $this->defaults->getName()
- ),
- 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.')
- );
- }
-
- if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
- $errors[] = array(
- 'error' => $this->l10n->t(
- 'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' .
- 'This will lead to problems with files over 4 GB and is highly discouraged.',
- $this->defaults->getName()
- ),
- 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.')
- );
- }
- if(!function_exists('curl_init') && PHP_INT_SIZE === 4) {
- $errors[] = array(
- 'error' => $this->l10n->t(
- 'It seems that this %s instance is running on a 32-bit PHP environment and cURL is not installed. ' .
- 'This will lead to problems with files over 4 GB and is highly discouraged.',
- $this->defaults->getName()
- ),
- 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.')
- );
- }
-
- return array(
- 'hasSQLite' => isset($databases['sqlite']),
- 'hasMySQL' => isset($databases['mysql']),
- 'hasPostgreSQL' => isset($databases['pgsql']),
- 'hasOracle' => isset($databases['oci']),
- 'hasMSSQL' => isset($databases['mssql']),
- 'databases' => $databases,
- 'directory' => $dataDir,
- 'htaccessWorking' => $htAccessWorking,
- 'errors' => $errors,
- );
- }
}
diff --git a/lib/base.php b/lib/base.php
index e957d6be089..107ae059bb1 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -566,7 +566,7 @@ class OC {
} catch(\Exception $e) {
echo('Writing to database failed');
}
- exit();
+ exit(1);
} else {
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
OC_Template::printGuestPage('', 'error', array('errors' => $errors));
@@ -747,7 +747,8 @@ class OC {
// Check if ownCloud is installed or in maintenance (update) mode
if (!$systemConfig->getValue('installed', false)) {
\OC::$server->getSession()->clear();
- $controller = new OC\Core\Setup\Controller(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), \OC::$server->getL10N('core'), new \OC_Defaults());
+ $setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults());
+ $controller = new OC\Core\Setup\Controller($setupHelper);
$controller->run($_POST);
exit();
}
diff --git a/lib/private/connector/sabre/exceptionloggerplugin.php b/lib/private/connector/sabre/exceptionloggerplugin.php
index 2bd43e56f55..a0dc6e7c182 100644
--- a/lib/private/connector/sabre/exceptionloggerplugin.php
+++ b/lib/private/connector/sabre/exceptionloggerplugin.php
@@ -10,6 +10,10 @@
namespace OC\Connector\Sabre;
+use OCP\ILogger;
+use Sabre\DAV\Exception;
+use Sabre\HTTP\Response;
+
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
private $nonFatalExceptions = array(
'Sabre\DAV\Exception\NotAuthenticated' => true,
@@ -22,13 +26,19 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
'Sabre\DAV\Exception\PreconditionFailed' => true,
);
+ /** @var string */
private $appName;
+ /** @var ILogger */
+ private $logger;
+
/**
* @param string $loggerAppName app name to use when logging
+ * @param ILogger $logger
*/
- public function __construct($loggerAppName = 'webdav') {
+ public function __construct($loggerAppName, $logger) {
$this->appName = $loggerAppName;
+ $this->logger = $logger;
}
/**
@@ -50,14 +60,30 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
/**
* Log exception
*
- * @internal param Exception $e exception
*/
- public function logException($e) {
- $exceptionClass = get_class($e);
+ public function logException(\Exception $ex) {
+ $exceptionClass = get_class($ex);
$level = \OCP\Util::FATAL;
if (isset($this->nonFatalExceptions[$exceptionClass])) {
$level = \OCP\Util::DEBUG;
}
- \OCP\Util::logException($this->appName, $e, $level);
+
+ $message = $ex->getMessage();
+ if ($ex instanceof Exception) {
+ if (empty($message)) {
+ $response = new Response($ex->getHTTPCode());
+ $message = $response->getStatusText();
+ }
+ $message = "HTTP/1.1 {$ex->getHTTPCode()} $message";
+ }
+
+ $exception = [
+ 'Message' => $message,
+ 'Code' => $ex->getCode(),
+ 'Trace' => $ex->getTraceAsString(),
+ 'File' => $ex->getFile(),
+ 'Line' => $ex->getLine(),
+ ];
+ $this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
}
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index f14209fd925..8b448abeb89 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1572,7 +1572,7 @@ class View {
} catch (ReservedWordException $ex) {
throw new InvalidPathException($l10n->t('File name is a reserved word'));
} catch (InvalidCharacterInPathException $ex) {
- throw new InvalidPathException($l10n->t('File name contains at least one invalid characters'));
+ throw new InvalidPathException($l10n->t('File name contains at least one invalid character'));
}
}
}
diff --git a/lib/private/installer.php b/lib/private/installer.php
index 087bc6c1edb..3956e503767 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -202,20 +202,21 @@ class OC_Installer{
/**
* update an app by it's id
- * @param integer $ocsid
+ *
+ * @param integer $ocsId
* @return bool
* @throws Exception
*/
- public static function updateAppByOCSId($ocsid) {
- $appdata = OCSClient::getApplication($ocsid);
- $download = OCSClient::getApplicationDownload($ocsid, 1);
+ public static function updateAppByOCSId($ocsId) {
+ $appData = OCSClient::getApplication($ocsId);
+ $download = OCSClient::getApplicationDownload($ocsId, 1);
if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') {
$download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
$info = array(
'source' => 'http',
'href' => $download['downloadlink'],
- 'appdata' => $appdata
+ 'appdata' => $appData
);
} else {
throw new \Exception('Could not fetch app info!');
@@ -285,7 +286,7 @@ class OC_Installer{
* @return array
* @throws \Exception
*/
- public static function checkAppsIntegrity($data = array(), $extractDir, $path, $isShipped=false) {
+ public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped=false) {
$l = \OC::$server->getL10N('lib');
//load the info.xml file of the app
if(!is_file($extractDir.'/appinfo/info.xml')) {
diff --git a/lib/private/preview.php b/lib/private/preview.php
index f45cc0858c7..6af1586293f 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -713,6 +713,7 @@ class Preview {
* - OC\Preview\Illustrator
* - OC\Preview\Postscript
* - OC\Preview\Photoshop
+ * - OC\Preview\Font
*/
if(empty(self::$enabledProviders)) {
self::$enabledProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', array(
@@ -772,8 +773,8 @@ class Preview {
'PDF' => 'OC\Preview\PDF',
'AI' => 'OC\Preview\Illustrator',
'PSD' => 'OC\Preview\Photoshop',
- // Requires adding 'eps' => array('application/postscript', null), to lib/private/mimetypes.list.php
'EPS' => 'OC\Preview\Postscript',
+ 'TTF' => 'OC\Preview\Font',
);
foreach ($imagickProviders as $queryFormat => $provider) {
diff --git a/lib/private/preview/font.php b/lib/private/preview/font.php
new file mode 100644
index 00000000000..58d64e8264d
--- /dev/null
+++ b/lib/private/preview/font.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @copyright Olivier Paroz 2015 <owncloud@interfasys.ch>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Preview;
+
+// .otf, .ttf and .pfb
+class Font extends Bitmap {
+ /**
+ * {@inheritDoc}
+ */
+ public function getMimeType() {
+ return '/application\/(?:font-sfnt|x-font$)/';
+ }
+} \ No newline at end of file
diff --git a/lib/private/repair/repairlegacystorages.php b/lib/private/repair/repairlegacystorages.php
index ab123afeca6..027cb68eb1b 100644
--- a/lib/private/repair/repairlegacystorages.php
+++ b/lib/private/repair/repairlegacystorages.php
@@ -143,79 +143,105 @@ class RepairLegacyStorages extends BasicEmitter {
$dataDirId = 'local::' . $dataDir;
$count = 0;
+ $hasWarnings = false;
$this->connection->beginTransaction();
- try {
- // note: not doing a direct UPDATE with the REPLACE function
- // because regexp search/extract is needed and it is not guaranteed
- // to work on all database types
- $sql = 'SELECT `id`, `numeric_id` FROM `*PREFIX*storages`'
- . ' WHERE `id` LIKE ?'
- . ' ORDER BY `id`';
- $result = $this->connection->executeQuery($sql, array($dataDirId . '%'));
- while ($row = $result->fetch()) {
- $currentId = $row['id'];
- // one entry is the datadir itself
- if ($currentId === $dataDirId) {
- continue;
- }
+ // note: not doing a direct UPDATE with the REPLACE function
+ // because regexp search/extract is needed and it is not guaranteed
+ // to work on all database types
+ $sql = 'SELECT `id`, `numeric_id` FROM `*PREFIX*storages`'
+ . ' WHERE `id` LIKE ?'
+ . ' ORDER BY `id`';
+ $result = $this->connection->executeQuery($sql, array($dataDirId . '%'));
+
+ while ($row = $result->fetch()) {
+ $currentId = $row['id'];
+ // one entry is the datadir itself
+ if ($currentId === $dataDirId) {
+ continue;
+ }
+ try {
if ($this->fixLegacyStorage($currentId, (int)$row['numeric_id'])) {
$count++;
}
}
+ catch (\OC\RepairException $e) {
+ $hasWarnings = true;
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Could not repair legacy storage ' . $currentId . ' automatically.')
+ );
+ }
+ }
- // check for md5 ids, not in the format "prefix::"
- $sql = 'SELECT COUNT(*) AS "c" FROM `*PREFIX*storages`'
- . ' WHERE `id` NOT LIKE \'%::%\'';
- $result = $this->connection->executeQuery($sql);
- $row = $result->fetch();
- // find at least one to make sure it's worth
- // querying the user list
- if ((int)$row['c'] > 0) {
- $userManager = \OC_User::getManager();
-
- // use chunks to avoid caching too many users in memory
- $limit = 30;
- $offset = 0;
-
- do {
- // query the next page of users
- $results = $userManager->search('', $limit, $offset);
- $storageIds = array();
- $userIds = array();
- foreach ($results as $uid => $userObject) {
- $storageId = $dataDirId . $uid . '/';
- if (strlen($storageId) <= 64) {
- // skip short storage ids as they were handled in the previous section
- continue;
- }
- $storageIds[$uid] = $storageId;
+ // check for md5 ids, not in the format "prefix::"
+ $sql = 'SELECT COUNT(*) AS "c" FROM `*PREFIX*storages`'
+ . ' WHERE `id` NOT LIKE \'%::%\'';
+ $result = $this->connection->executeQuery($sql);
+ $row = $result->fetch();
+
+ // find at least one to make sure it's worth
+ // querying the user list
+ if ((int)$row['c'] > 0) {
+ $userManager = \OC_User::getManager();
+
+ // use chunks to avoid caching too many users in memory
+ $limit = 30;
+ $offset = 0;
+
+ do {
+ // query the next page of users
+ $results = $userManager->search('', $limit, $offset);
+ $storageIds = array();
+ $userIds = array();
+ foreach ($results as $uid => $userObject) {
+ $storageId = $dataDirId . $uid . '/';
+ if (strlen($storageId) <= 64) {
+ // skip short storage ids as they were handled in the previous section
+ continue;
}
+ $storageIds[$uid] = $storageId;
+ }
- if (count($storageIds) > 0) {
- // update the storages of these users
- foreach ($storageIds as $uid => $storageId) {
- $numericId = \OC\Files\Cache\Storage::getNumericStorageId($storageId);
+ if (count($storageIds) > 0) {
+ // update the storages of these users
+ foreach ($storageIds as $uid => $storageId) {
+ $numericId = \OC\Files\Cache\Storage::getNumericStorageId($storageId);
+ try {
if (!is_null($numericId) && $this->fixLegacyStorage($storageId, (int)$numericId)) {
$count++;
}
}
+ catch (\OC\RepairException $e) {
+ $hasWarnings = true;
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Could not repair legacy storage ' . $storageId . ' automatically.')
+ );
+ }
}
- $offset += $limit;
- } while (count($results) >= $limit);
- }
+ }
+ $offset += $limit;
+ } while (count($results) >= $limit);
+ }
- $this->emit('\OC\Repair', 'info', array('Updated ' . $count . ' legacy home storage ids'));
+ $this->emit('\OC\Repair', 'info', array('Updated ' . $count . ' legacy home storage ids'));
- $this->connection->commit();
- }
- catch (\OC\RepairException $e) {
- $this->connection->rollback();
- throw $e;
- }
+ $this->connection->commit();
- $this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+ if ($hasWarnings) {
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Some legacy storages could not be repaired. Please manually fix them then re-run ./occ maintenance:repair')
+ );
+ } else {
+ // if all were done, no need to redo the repair during next upgrade
+ $this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+ }
}
}
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 064afecbfe8..1da42f0f8a4 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -8,19 +8,34 @@
namespace OC;
+use bantu\IniGetWrapper\IniGetWrapper;
use Exception;
-use OC_L10N;
use OCP\IConfig;
+use OCP\IL10N;
class Setup {
- /** @var IConfig */
+ /** @var \OCP\IConfig */
protected $config;
+ /** @var IniGetWrapper */
+ protected $iniWrapper;
+ /** @var IL10N */
+ protected $l10n;
+ /** @var \OC_Defaults */
+ protected $defaults;
/**
* @param IConfig $config
+ * @param IniGetWrapper $iniWrapper
+ * @param \OC_Defaults $defaults
*/
- function __construct(IConfig $config) {
+ function __construct(IConfig $config,
+ IniGetWrapper $iniWrapper,
+ IL10N $l10n,
+ \OC_Defaults $defaults) {
$this->config = $config;
+ $this->iniWrapper = $iniWrapper;
+ $this->l10n = $l10n;
+ $this->defaults = $defaults;
}
static $dbSetupClasses = array(
@@ -33,13 +48,6 @@ class Setup {
);
/**
- * @return OC_L10N
- */
- public static function getTrans(){
- return \OC::$server->getL10N('lib');
- }
-
- /**
* Wrapper around the "class_exists" PHP function to be able to mock it
* @param string $name
* @return bool
@@ -117,11 +125,90 @@ class Setup {
}
/**
+ * Gathers system information like database type and does
+ * a few system checks.
+ *
+ * @return array of system info, including an "errors" value
+ * in case of errors/warnings
+ */
+ public function getSystemInfo() {
+ $databases = $this->getSupportedDatabases();
+
+ $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
+
+ $errors = array();
+
+ // Create data directory to test whether the .htaccess works
+ // Notice that this is not necessarily the same data directory as the one
+ // that will effectively be used.
+ @mkdir($dataDir);
+ $htAccessWorking = true;
+ if (is_dir($dataDir) && is_writable($dataDir)) {
+ // Protect data directory here, so we can test if the protection is working
+ \OC\Setup::protectDataDirectory();
+
+ try {
+ $htAccessWorking = \OC_Util::isHtaccessWorking();
+ } catch (\OC\HintException $e) {
+ $errors[] = array(
+ 'error' => $e->getMessage(),
+ 'hint' => $e->getHint()
+ );
+ $htAccessWorking = false;
+ }
+ }
+
+ if (\OC_Util::runningOnMac()) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'Mac OS X is not supported and %s will not work properly on this platform. ' .
+ 'Use it at your own risk! ',
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.')
+ );
+ }
+
+ if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' .
+ 'This will lead to problems with files over 4 GB and is highly discouraged.',
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.')
+ );
+ }
+ if(!function_exists('curl_init') && PHP_INT_SIZE === 4) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'It seems that this %s instance is running on a 32-bit PHP environment and cURL is not installed. ' .
+ 'This will lead to problems with files over 4 GB and is highly discouraged.',
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.')
+ );
+ }
+
+ return array(
+ 'hasSQLite' => isset($databases['sqlite']),
+ 'hasMySQL' => isset($databases['mysql']),
+ 'hasPostgreSQL' => isset($databases['pgsql']),
+ 'hasOracle' => isset($databases['oci']),
+ 'hasMSSQL' => isset($databases['mssql']),
+ 'databases' => $databases,
+ 'directory' => $dataDir,
+ 'htaccessWorking' => $htAccessWorking,
+ 'errors' => $errors,
+ );
+ }
+
+ /**
* @param $options
* @return array
*/
- public static function install($options) {
- $l = self::getTrans();
+ public function install($options) {
+ $l = $this->l10n;
$error = array();
$dbType = $options['dbtype'];
@@ -146,7 +233,7 @@ class Setup {
$class = self::$dbSetupClasses[$dbType];
/** @var \OC\Setup\AbstractDatabase $dbSetup */
- $dbSetup = new $class(self::getTrans(), 'db_structure.xml');
+ $dbSetup = new $class($l, 'db_structure.xml');
$error = array_merge($error, $dbSetup->validate($options));
// validate the data directory
@@ -186,7 +273,7 @@ class Setup {
$secret = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(48);
//write the config file
- \OC::$server->getConfig()->setSystemValues([
+ $this->config->setSystemValues([
'passwordsalt' => $salt,
'secret' => $secret,
'trusted_domains' => $trustedDomains,
@@ -281,7 +368,7 @@ class Setup {
* @throws \OC\HintException If .htaccess does not include the current version
*/
public static function updateHtaccess() {
- $setupHelper = new \OC\Setup(\OC::$server->getConfig());
+ $setupHelper = new \OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults());
if(!$setupHelper->isCurrentHtaccess()) {
throw new \OC\HintException('.htaccess file has the wrong version. Please upload the correct version. Maybe you forgot to replace it after updating?');
}
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php
index 6059af0196d..55b71ceeeac 100644
--- a/lib/private/share/helper.php
+++ b/lib/private/share/helper.php
@@ -221,4 +221,34 @@ class Helper extends \OC\Share\Constants {
return $expires;
}
+
+ /**
+ * Extracts the necessary remote name from a given link
+ *
+ * Strips away a potential file name, to allow
+ * - user
+ * - user@localhost
+ * - user@http://localhost
+ * - user@http://localhost/
+ * - user@http://localhost/index.php
+ * - user@http://localhost/index.php/s/{shareToken}
+ *
+ * @param string $shareWith
+ * @return string
+ */
+ public static function fixRemoteURLInShareWith($shareWith) {
+ if (strpos($shareWith, '@')) {
+ list($user, $remote) = explode('@', $shareWith, 2);
+
+ $remote = str_replace('\\', '/', $remote);
+ if ($fileNamePosition = strpos($remote, '/index.php')) {
+ $remote = substr($remote, 0, $fileNamePosition);
+ }
+ $remote = rtrim($remote, '/');
+
+ $shareWith = $user . '@' . $remote;
+ }
+
+ return rtrim($shareWith, '/');
+ }
}
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 4753f6ecbfa..974ebf41f93 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -724,7 +724,7 @@ class Share extends \OC\Share\Constants {
$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
\OCP\Security\ISecureRandom::CHAR_DIGITS);
- $shareWith = rtrim($shareWith, '/');
+ $shareWith = Helper::fixRemoteURLInShareWith($shareWith);
$shareId = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token, $itemSourceName);
$send = false;
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 71ada3217e0..302003e666c 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -173,6 +173,20 @@ class Updater extends BasicEmitter {
}
/**
+ * Forward messages emitted by the repair routine
+ *
+ * @param Repair $repair repair routine
+ */
+ private function emitRepairMessages(Repair $repair) {
+ $repair->listen('\OC\Repair', 'warning', function ($description) {
+ $this->emit('\OC\Updater', 'repairWarning', array($description));
+ });
+ $repair->listen('\OC\Repair', 'error', function ($description) {
+ $this->emit('\OC\Updater', 'repairError', array($description));
+ });
+ }
+
+ /**
* runs the update actions in maintenance mode, does not upgrade the source files
* except the main .htaccess file
*
@@ -204,6 +218,7 @@ class Updater extends BasicEmitter {
// pre-upgrade repairs
$repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
+ $this->emitRepairMessages($repair);
$repair->run();
// simulate DB upgrade
@@ -223,6 +238,7 @@ class Updater extends BasicEmitter {
// post-upgrade repairs
$repair = new Repair(Repair::getRepairSteps());
+ $this->emitRepairMessages($repair);
$repair->run();
//Invalidate update feed
diff --git a/lib/private/util.php b/lib/private/util.php
index 62bbf5cf2aa..72802409da9 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -497,7 +497,7 @@ class OC_Util {
}
$webServerRestart = false;
- $setup = new OC\Setup($config);
+ $setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults());
$availableDatabases = $setup->getSupportedDatabases();
if (empty($availableDatabases)) {
$errors[] = array(
@@ -702,7 +702,7 @@ class OC_Util {
);
}
- if ($webServerRestart) {
+ if (!\OC::$CLI && $webServerRestart) {
$errors[] = array(
'error' => $l->t('PHP modules have been installed, but they are still listed as missing?'),
'hint' => $l->t('Please ask your server administrator to restart the web server.')
diff --git a/settings/js/apps.js b/settings/js/apps.js
index c15d6a0f74d..7330f426af7 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -235,7 +235,11 @@ OC.Settings.Apps = OC.Settings.Apps || {
OC.Settings.Apps.hideErrorMessage(appId);
$.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appId},function(result) {
if(!result || result.status !== 'success') {
- OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while updating app'));
+ if (result.data && result.data.message) {
+ OC.Settings.Apps.showErrorMessage(appId, result.data.message);
+ } else {
+ OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while updating app'));
+ }
element.val(oldButtonText);
}
else {
diff --git a/tests/lib/connector/sabre/exceptionloggerplugin.php b/tests/lib/connector/sabre/exceptionloggerplugin.php
new file mode 100644
index 00000000000..0662ba029d9
--- /dev/null
+++ b/tests/lib/connector/sabre/exceptionloggerplugin.php
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * Copyright (c) 2015 Thomas Müller <deepdiver@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Connector\Sabre;
+
+use OC\Connector\Sabre\Exception\InvalidPath;
+use OC\Connector\Sabre\ExceptionLoggerPlugin as PluginToTest;
+use OC\Log;
+use OCP\ILogger;
+use PHPUnit_Framework_MockObject_MockObject;
+use Sabre\DAV\Exception\NotFound;
+use Sabre\DAV\Server;
+use Test\TestCase;
+
+class TestLogger extends Log {
+ public $message;
+ public $level;
+
+ public function __construct($logger = null) {
+ //disable original constructor
+ }
+
+ public function log($level, $message, array $context = array()) {
+ $this->level = $level;
+ $this->message = $message;
+ }
+}
+
+class ExceptionLoggerPlugin extends TestCase {
+
+ /** @var Server */
+ private $server;
+
+ /** @var PluginToTest */
+ private $plugin;
+
+ /** @var TestLogger | PHPUnit_Framework_MockObject_MockObject */
+ private $logger;
+
+ private function init() {
+ $this->server = new Server();
+ $this->logger = new TestLogger();
+ $this->plugin = new PluginToTest('unit-test', $this->logger);
+ $this->plugin->initialize($this->server);
+ }
+
+ /**
+ * @dataProvider providesExceptions
+ */
+ public function testLogging($expectedLogLevel, $expectedMessage, $exception) {
+ $this->init();
+ $this->plugin->logException($exception);
+
+ $this->assertEquals($expectedLogLevel, $this->logger->level);
+ $this->assertStringStartsWith('Exception: {"Message":"' . $expectedMessage, $this->logger->message);
+ }
+
+ public function providesExceptions() {
+ return [
+ [0, 'HTTP\/1.1 404 Not Found', new NotFound()],
+ [4, 'HTTP\/1.1 400 This path leads to nowhere', new InvalidPath('This path leads to nowhere')]
+ ];
+ }
+
+}
diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php
index f2812e390ac..74e289c1751 100644
--- a/tests/lib/connector/sabre/file.php
+++ b/tests/lib/connector/sabre/file.php
@@ -8,9 +8,6 @@
namespace Test\Connector\Sabre;
-
-use OC_Connector_Sabre_File;
-
class File extends \Test\TestCase {
/**
diff --git a/tests/lib/repair/repairlegacystorage.php b/tests/lib/repair/repairlegacystorage.php
index f08393300e1..4167ddff85a 100644
--- a/tests/lib/repair/repairlegacystorage.php
+++ b/tests/lib/repair/repairlegacystorage.php
@@ -24,6 +24,8 @@ class TestRepairLegacyStorages extends \Test\TestCase {
private $legacyStorageId;
private $newStorageId;
+ private $warnings;
+
protected function setUp() {
parent::setUp();
@@ -32,6 +34,12 @@ class TestRepairLegacyStorages extends \Test\TestCase {
$this->oldDataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
$this->repair = new \OC\Repair\RepairLegacyStorages($this->config, $this->connection);
+
+ $this->warnings = [];
+
+ $this->repair->listen('\OC\Repair', 'warning', function ($description){
+ $this->warnings[] = $description;
+ });
}
protected function tearDown() {
@@ -181,21 +189,16 @@ class TestRepairLegacyStorages extends \Test\TestCase {
$this->createData($this->legacyStorageId);
$this->createData($this->newStorageId);
- try {
- $thrown = false;
- $this->repair->run();
- }
- catch (\OC\RepairException $e) {
- $thrown = true;
- }
+ $this->repair->run();
- $this->assertTrue($thrown);
+ $this->assertEquals(2, count($this->warnings));
+ $this->assertEquals('Could not repair legacy storage ', substr(current($this->warnings), 0, 32));
// storages left alone
$this->assertEquals($legacyStorageNumId, $this->getStorageId($this->legacyStorageId));
$this->assertEquals($newStorageNumId, $this->getStorageId($this->newStorageId));
- // did not set the done flag
+ // do not set the done flag
$this->assertNotEquals('yes', $this->config->getAppValue('core', 'repairlegacystoragesdone'));
}
diff --git a/tests/lib/setup.php b/tests/lib/setup.php
index db6f0e7a05f..caaeec08fb3 100644
--- a/tests/lib/setup.php
+++ b/tests/lib/setup.php
@@ -10,16 +10,27 @@ use OCP\IConfig;
class Test_OC_Setup extends \Test\TestCase {
- /** @var IConfig */
+ /** @var IConfig | PHPUnit_Framework_MockObject_MockObject */
protected $config;
- /** @var \OC\Setup */
+ /** @var \bantu\IniGetWrapper\IniGetWrapper | PHPUnit_Framework_MockObject_MockObject */
+ private $iniWrapper;
+ /** @var \OCP\IL10N | PHPUnit_Framework_MockObject_MockObject */
+ private $l10n;
+ /** @var \OC_Defaults | PHPUnit_Framework_MockObject_MockObject */
+ private $defaults;
+ /** @var \OC\Setup | PHPUnit_Framework_MockObject_MockObject */
protected $setupClass;
protected function setUp() {
parent::setUp();
$this->config = $this->getMock('\OCP\IConfig');
- $this->setupClass = $this->getMock('\OC\Setup', ['class_exists', 'is_callable'], [$this->config]);
+ $this->iniWrapper = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper');
+ $this->l10n = $this->getMock('\OCP\IL10N');
+ $this->defaults = $this->getMock('\OC_Defaults');
+ $this->setupClass = $this->getMock('\OC\Setup',
+ ['class_exists', 'is_callable'],
+ [$this->config, $this->iniWrapper, $this->l10n, $this->defaults]);
}
public function testGetSupportedDatabasesWithOneWorking() {
diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php
index 7a546410aea..0385263fd91 100644
--- a/tests/lib/share/helper.php
+++ b/tests/lib/share/helper.php
@@ -49,4 +49,55 @@ class Test_Share_Helper extends \Test\TestCase {
$result = \OC\Share\Helper::calculateExpireDate($defaultExpireSettings, $creationTime, $userExpireDate);
$this->assertSame($expected, $result);
}
+
+ public function fixRemoteURLInShareWithData() {
+ $userPrefix = ['test@', 'na/me@'];
+ $protocols = ['', 'http://', 'https://'];
+ $remotes = [
+ 'localhost',
+ 'test:foobar@localhost',
+ 'local.host',
+ 'dev.local.host',
+ 'dev.local.host/path',
+ '127.0.0.1',
+ '::1',
+ '::192.0.2.128',
+ ];
+
+ $testCases = [
+ ['test', 'test'],
+ ['na/me', 'na/me'],
+ ['na/me/', 'na/me'],
+ ['na/index.php', 'na/index.php'],
+ ['http://localhost', 'http://localhost'],
+ ['http://localhost/', 'http://localhost'],
+ ['http://localhost/index.php', 'http://localhost/index.php'],
+ ['http://localhost/index.php/s/token', 'http://localhost/index.php/s/token'],
+ ['http://test:foobar@localhost', 'http://test:foobar@localhost'],
+ ['http://test:foobar@localhost/', 'http://test:foobar@localhost'],
+ ['http://test:foobar@localhost/index.php', 'http://test:foobar@localhost'],
+ ['http://test:foobar@localhost/index.php/s/token', 'http://test:foobar@localhost'],
+ ];
+
+ foreach ($userPrefix as $user) {
+ foreach ($remotes as $remote) {
+ foreach ($protocols as $protocol) {
+ $baseUrl = $user . $protocol . $remote;
+
+ $testCases[] = [$baseUrl, $baseUrl];
+ $testCases[] = [$baseUrl . '/', $baseUrl];
+ $testCases[] = [$baseUrl . '/index.php', $baseUrl];
+ $testCases[] = [$baseUrl . '/index.php/s/token', $baseUrl];
+ }
+ }
+ }
+ return $testCases;
+ }
+
+ /**
+ * @dataProvider fixRemoteURLInShareWithData
+ */
+ public function testFixRemoteURLInShareWith($remote, $expected) {
+ $this->assertSame($expected, \OC\Share\Helper::fixRemoteURLInShareWith($remote));
+ }
}