summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/appframework/app.php40
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php5
-rw-r--r--lib/private/appframework/http/dispatcher.php10
-rw-r--r--lib/private/appframework/http/output.php70
-rw-r--r--lib/private/db/statementwrapper.php102
-rw-r--r--lib/private/files/cache/updater.php22
-rw-r--r--lib/private/files/node/node.php23
-rw-r--r--lib/private/files/view.php7
-rw-r--r--lib/private/repair.php2
-rw-r--r--lib/private/util.php58
10 files changed, 192 insertions, 147 deletions
diff --git a/lib/private/appframework/app.php b/lib/private/appframework/app.php
index 537f10255a3..6d54b931d5a 100644
--- a/lib/private/appframework/app.php
+++ b/lib/private/appframework/app.php
@@ -24,9 +24,10 @@
namespace OC\AppFramework;
-use \OC_App;
-use \OC\AppFramework\DependencyInjection\DIContainer;
-use \OCP\AppFramework\QueryException;
+use OC_App;
+use OC\AppFramework\DependencyInjection\DIContainer;
+use OCP\AppFramework\QueryException;
+use OCP\AppFramework\Http\ICallbackResponse;
/**
* Entry point for every request in your app. You can consider this as your
@@ -93,15 +94,22 @@ class App {
// initialize the dispatcher and run all the middleware before the controller
$dispatcher = $container['Dispatcher'];
- list($httpHeaders, $responseHeaders, $responseCookies, $output) =
- $dispatcher->dispatch($controller, $methodName);
+ list(
+ $httpHeaders,
+ $responseHeaders,
+ $responseCookies,
+ $output,
+ $response
+ ) = $dispatcher->dispatch($controller, $methodName);
+
+ $io = $container['OCP\\AppFramework\\Http\\IOutput'];
if(!is_null($httpHeaders)) {
- header($httpHeaders);
+ $io->setHeader($httpHeaders);
}
foreach($responseHeaders as $name => $value) {
- header($name . ': ' . $value);
+ $io->setHeader($name . ': ' . $value);
}
foreach($responseCookies as $name => $value) {
@@ -109,12 +117,22 @@ class App {
if($value['expireDate'] instanceof \DateTime) {
$expireDate = $value['expireDate']->getTimestamp();
}
- setcookie($name, $value['value'], $expireDate, $container->getServer()->getWebRoot(), null, $container->getServer()->getConfig()->getSystemValue('forcessl', false), true);
+ $io->setCookie(
+ $name,
+ $value['value'],
+ $expireDate,
+ $container->getServer()->getWebRoot(),
+ null,
+ $container->getServer()->getConfig()->getSystemValue('forcessl', false),
+ true
+ );
}
- if(!is_null($output)) {
- header('Content-Length: ' . strlen($output));
- print($output);
+ if ($response instanceof ICallbackResponse) {
+ $response->callback($io);
+ } else if(!is_null($output)) {
+ $io->setHeader('Content-Length: ' . strlen($output));
+ $io->setOutput($output);
}
}
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
index 4229b251e29..e88177c6398 100644
--- a/lib/private/appframework/dependencyinjection/dicontainer.php
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -28,6 +28,7 @@ use OC;
use OC\AppFramework\Http;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Http\Dispatcher;
+use OC\AppFramework\Http\Output;
use OC\AppFramework\Core\API;
use OC\AppFramework\Middleware\MiddlewareDispatcher;
use OC\AppFramework\Middleware\Security\SecurityMiddleware;
@@ -69,6 +70,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer()->getAppManager();
});
+ $this->registerService('OCP\\AppFramework\\Http\\IOutput', function($c){
+ return new Output();
+ });
+
$this->registerService('OCP\\IAvatarManager', function($c) {
return $this->getServer()->getAvatarManager();
});
diff --git a/lib/private/appframework/http/dispatcher.php b/lib/private/appframework/http/dispatcher.php
index 24540ef3c94..910e9c32ed4 100644
--- a/lib/private/appframework/http/dispatcher.php
+++ b/lib/private/appframework/http/dispatcher.php
@@ -100,17 +100,15 @@ class Dispatcher {
$response = $this->middlewareDispatcher->afterController(
$controller, $methodName, $response);
- // get the output which should be printed and run the after output
- // middleware to modify the response
- $output = $response->render();
- $out[3] = $this->middlewareDispatcher->beforeOutput(
- $controller, $methodName, $output);
-
// depending on the cache object the headers need to be changed
$out[0] = $this->protocol->getStatusHeader($response->getStatus(),
$response->getLastModified(), $response->getETag());
$out[1] = array_merge($response->getHeaders());
$out[2] = $response->getCookies();
+ $out[3] = $this->middlewareDispatcher->beforeOutput(
+ $controller, $methodName, $response->render()
+ );
+ $out[4] = $response;
return $out;
}
diff --git a/lib/private/appframework/http/output.php b/lib/private/appframework/http/output.php
new file mode 100644
index 00000000000..808f1ec6dfd
--- /dev/null
+++ b/lib/private/appframework/http/output.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * @author Bernhard Posselt
+ * @copyright 2015 Bernhard Posselt <dev@bernhard-posselt.com>
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\AppFramework\Http;
+
+use OCP\AppFramework\Http\IOutput;
+
+/**
+ * Very thin wrapper class to make output testable
+ */
+class Output implements IOutput {
+
+ /**
+ * @param string $out
+ */
+ public function setOutput($out) {
+ print($out);
+ }
+
+ /**
+ * @param string $path
+ *
+ * @return bool false if an error occured
+ */
+ public function setReadfile($path) {
+ return @readfile($path);
+ }
+
+ /**
+ * @param string $header
+ */
+ public function setHeader($header) {
+ header($header);
+ }
+
+ /**
+ * @param int $code sets the http status code
+ */
+ public function setHttpResponseCode($code) {
+ http_response_code($code);
+ }
+
+ /**
+ * @return int returns the current http response code
+ */
+ public function getHttpResponseCode() {
+ return http_response_code();
+ }
+
+ /**
+ * @param string $name
+ * @param string $value
+ * @param int $expire
+ * @param string $path
+ * @param string $domain
+ * @param bool $secure
+ * @param bool $httponly
+ */
+ public function setCookie($name, $value, $expire, $path, $domain, $secure, $httponly) {
+ setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
+ }
+
+}
diff --git a/lib/private/db/statementwrapper.php b/lib/private/db/statementwrapper.php
index d73347d4363..c74a74e4ae2 100644
--- a/lib/private/db/statementwrapper.php
+++ b/lib/private/db/statementwrapper.php
@@ -51,15 +51,6 @@ class OC_DB_StatementWrapper {
}
$this->lastArguments = $input;
if (count($input) > 0) {
-
- if (!isset($type)) {
- $type = OC_Config::getValue( "dbtype", "sqlite" );
- }
-
- if ($type == 'mssql') {
- $input = $this->tryFixSubstringLastArgumentDataForMSSQL($input);
- }
-
$result = $this->statement->execute($input);
} else {
$result = $this->statement->execute();
@@ -76,99 +67,6 @@ class OC_DB_StatementWrapper {
}
}
- private function tryFixSubstringLastArgumentDataForMSSQL($input) {
- $query = $this->statement->getWrappedStatement()->queryString;
- $pos = stripos ($query, 'SUBSTRING');
-
- if ( $pos === false) {
- return $input;
- }
-
- try {
- $newQuery = '';
-
- $cArg = 0;
-
- $inSubstring = false;
- $queryLength = strlen($query);
-
- // Create new query
- for ($i = 0; $i < $queryLength; $i++) {
- if ($inSubstring == false) {
- // Defines when we should start inserting values
- if (substr ($query, $i, 9) == 'SUBSTRING') {
- $inSubstring = true;
- }
- } else {
- // Defines when we should stop inserting values
- if (substr ($query, $i, 1) == ')') {
- $inSubstring = false;
- }
- }
-
- if (substr ($query, $i, 1) == '?') {
- // We found a question mark
- if ($inSubstring) {
- $newQuery .= $input[$cArg];
-
- //
- // Remove from input array
- //
- array_splice ($input, $cArg, 1);
- } else {
- $newQuery .= substr ($query, $i, 1);
- $cArg++;
- }
- } else {
- $newQuery .= substr ($query, $i, 1);
- }
- }
-
- // The global data we need
- $name = OC_Config::getValue( "dbname", "owncloud" );
- $host = OC_Config::getValue( "dbhost", "" );
- $user = OC_Config::getValue( "dbuser", "" );
- $pass = OC_Config::getValue( "dbpassword", "" );
- if (strpos($host, ':')) {
- list($host, $port) = explode(':', $host, 2);
- } else {
- $port = false;
- }
- $opts = array();
-
- if ($port) {
- $dsn = 'sqlsrv:Server='.$host.','.$port.';Database='.$name;
- } else {
- $dsn = 'sqlsrv:Server='.$host.';Database='.$name;
- }
-
- $PDO = new PDO($dsn, $user, $pass, $opts);
- $PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
- $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- $this->statement = $PDO->prepare($newQuery);
-
- $this->lastArguments = $input;
-
- return $input;
- } catch (PDOException $e){
- $entry = 'PDO DB Error: "'.$e->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$this->statement->queryString .'<br />';
- $entry .= 'Input parameters: ' .print_r($input, true).'<br />';
- $entry .= 'Stack trace: ' .$e->getTraceAsString().'<br />';
- OC_Log::write('core', $entry, OC_Log::FATAL);
- OC_User::setUserId(null);
-
- $l = \OC::$server->getL10N('lib');
- throw new \OC\HintException(
- $l->t('Database Error'),
- $l->t('Please contact your system administrator.'),
- 0,
- $e
- );
- }
- }
-
/**
* provide an alias for fetch
*
diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index 9f4cbfeff8c..248748ea4a9 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -13,6 +13,11 @@ namespace OC\Files\Cache;
*/
class Updater {
/**
+ * @var bool
+ */
+ protected $enabled = true;
+
+ /**
* @var \OC\Files\View
*/
protected $view;
@@ -30,6 +35,14 @@ class Updater {
$this->propagator = new ChangePropagator($view);
}
+ public function disable() {
+ $this->enabled = false;
+ }
+
+ public function enable() {
+ $this->enabled = true;
+ }
+
public function propagate($path, $time = null) {
if (Scanner::isPartialFile($path)) {
return;
@@ -45,7 +58,7 @@ class Updater {
* @param int $time
*/
public function update($path, $time = null) {
- if(Scanner::isPartialFile($path)) {
+ if (!$this->enabled or Scanner::isPartialFile($path)) {
return;
}
/**
@@ -70,7 +83,7 @@ class Updater {
* @param string $path
*/
public function remove($path) {
- if (Scanner::isPartialFile($path)) {
+ if (!$this->enabled or Scanner::isPartialFile($path)) {
return;
}
/**
@@ -97,7 +110,7 @@ class Updater {
* @param string $target
*/
public function rename($source, $target) {
- if (Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
+ if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
return;
}
/**
@@ -116,6 +129,9 @@ class Updater {
if ($sourceStorage && $targetStorage) {
if ($sourceStorage === $targetStorage) {
$cache = $sourceStorage->getCache($sourceInternalPath);
+ if ($cache->inCache($targetInternalPath)) {
+ $cache->remove($targetInternalPath);
+ }
$cache->move($sourceInternalPath, $targetInternalPath);
if (pathinfo($sourceInternalPath, PATHINFO_EXTENSION) !== pathinfo($targetInternalPath, PATHINFO_EXTENSION)) {
diff --git a/lib/private/files/node/node.php b/lib/private/files/node/node.php
index 9446bff603e..e5b219420cd 100644
--- a/lib/private/files/node/node.php
+++ b/lib/private/files/node/node.php
@@ -152,6 +152,8 @@ class Node implements \OCP\Files\Node {
/**
* @return int
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function getId() {
return $this->getFileInfo()->getId();
@@ -166,6 +168,8 @@ class Node implements \OCP\Files\Node {
/**
* @return int
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function getMTime() {
return $this->getFileInfo()->getMTime();
@@ -173,6 +177,8 @@ class Node implements \OCP\Files\Node {
/**
* @return int
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function getSize() {
return $this->getFileInfo()->getSize();
@@ -180,6 +186,8 @@ class Node implements \OCP\Files\Node {
/**
* @return string
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function getEtag() {
return $this->getFileInfo()->getEtag();
@@ -187,6 +195,8 @@ class Node implements \OCP\Files\Node {
/**
* @return int
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function getPermissions() {
return $this->getFileInfo()->getPermissions();
@@ -194,6 +204,8 @@ class Node implements \OCP\Files\Node {
/**
* @return bool
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function isReadable() {
return $this->getFileInfo()->isReadable();
@@ -201,6 +213,8 @@ class Node implements \OCP\Files\Node {
/**
* @return bool
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function isUpdateable() {
return $this->getFileInfo()->isUpdateable();
@@ -208,6 +222,8 @@ class Node implements \OCP\Files\Node {
/**
* @return bool
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function isDeletable() {
return $this->getFileInfo()->isDeletable();
@@ -215,11 +231,18 @@ class Node implements \OCP\Files\Node {
/**
* @return bool
+ * @throws InvalidPathException
+ * @throws NotFoundException
*/
public function isShareable() {
return $this->getFileInfo()->isShareable();
}
+ /**
+ * @return bool
+ * @throws InvalidPathException
+ * @throws NotFoundException
+ */
public function isCreatable() {
return $this->getFileInfo()->isCreatable();
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 9cf7eaa2ec1..4f9a4001d69 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1528,4 +1528,11 @@ class View {
$mount
);
}
+
+ /**
+ * @return Updater
+ */
+ public function getUpdater(){
+ return $this->updater;
+ }
}
diff --git a/lib/private/repair.php b/lib/private/repair.php
index d9fd99707e8..101af66e304 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -13,6 +13,7 @@ use OC\Hooks\Emitter;
use OC\Repair\AssetCache;
use OC\Repair\CleanTags;
use OC\Repair\Collation;
+use OC\Repair\DropOldTables;
use OC\Repair\FillETags;
use OC\Repair\InnoDB;
use OC\Repair\RepairConfig;
@@ -84,6 +85,7 @@ class Repair extends BasicEmitter {
new AssetCache(),
new FillETags(\OC_DB::getConnection()),
new CleanTags(\OC_DB::getConnection()),
+ new DropOldTables(\OC_DB::getConnection()),
);
}
diff --git a/lib/private/util.php b/lib/private/util.php
index 3f06f0efffc..3a0d7f653ed 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -608,36 +608,44 @@ class OC_Util {
$invalidIniSettings = [];
$moduleHint = $l->t('Please ask your server administrator to install the module.');
- foreach ($dependencies['classes'] as $class => $module) {
- if (!class_exists($class)) {
- $missingDependencies[] = $module;
- }
- }
- foreach ($dependencies['functions'] as $function => $module) {
- if (!function_exists($function)) {
- $missingDependencies[] = $module;
- }
- }
- foreach ($dependencies['defined'] as $defined => $module) {
- if (!defined($defined)) {
- $missingDependencies[] = $module;
+ /**
+ * FIXME: The dependency check does not work properly on HHVM on the moment
+ * and prevents installation. Once HHVM is more compatible with our
+ * approach to check for these values we should re-enable those
+ * checks.
+ */
+ if (!self::runningOnHhvm()) {
+ foreach ($dependencies['classes'] as $class => $module) {
+ if (!class_exists($class)) {
+ $missingDependencies[] = $module;
+ }
}
- }
- foreach($dependencies['ini'] as $setting => $expected) {
- $iniWrapper = \OC::$server->getIniWrapper();
- if(is_bool($expected)) {
- if($iniWrapper->getBool($setting) !== $expected) {
- $invalidIniSettings[] = [$setting, $expected];
+ foreach ($dependencies['functions'] as $function => $module) {
+ if (!function_exists($function)) {
+ $missingDependencies[] = $module;
}
}
- if(is_int($expected)) {
- if($iniWrapper->getNumeric($setting) !== $expected) {
- $invalidIniSettings[] = [$setting, $expected];
+ foreach ($dependencies['defined'] as $defined => $module) {
+ if (!defined($defined)) {
+ $missingDependencies[] = $module;
}
}
- if(is_string($expected)) {
- if(strtolower($iniWrapper->getString($setting)) !== strtolower($expected)) {
- $invalidIniSettings[] = [$setting, $expected];
+ foreach ($dependencies['ini'] as $setting => $expected) {
+ $iniWrapper = \OC::$server->getIniWrapper();
+ if (is_bool($expected)) {
+ if ($iniWrapper->getBool($setting) !== $expected) {
+ $invalidIniSettings[] = [$setting, $expected];
+ }
+ }
+ if (is_int($expected)) {
+ if ($iniWrapper->getNumeric($setting) !== $expected) {
+ $invalidIniSettings[] = [$setting, $expected];
+ }
+ }
+ if (is_string($expected)) {
+ if (strtolower($iniWrapper->getString($setting)) !== strtolower($expected)) {
+ $invalidIniSettings[] = [$setting, $expected];
+ }
}
}
}