summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-06-27 14:02:05 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-06-27 14:02:05 +0200
commit153ce2f9ab93f983fa9013c521f9b2a39a4adafb (patch)
tree5c4c1b28f32b9abe04b7115f8cb704287e31d7a7 /lib
parent4e53db3d9c2dfca6baf2e9878d14c38656b37bca (diff)
parent12f7cb87679453fa96c796df857b7e7193d4ee09 (diff)
downloadnextcloud-server-153ce2f9ab93f983fa9013c521f9b2a39a4adafb.tar.gz
nextcloud-server-153ce2f9ab93f983fa9013c521f9b2a39a4adafb.zip
Merge branch 'master' into calendar_import
Diffstat (limited to 'lib')
-rwxr-xr-xlib/app.php28
-rw-r--r--lib/base.php12
-rw-r--r--lib/connector/sabre/directory.php20
-rw-r--r--lib/helper.php3
-rw-r--r--lib/vcategories.php11
5 files changed, 45 insertions, 29 deletions
diff --git a/lib/app.php b/lib/app.php
index b337c55ec60..a9feff1620a 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -84,6 +84,7 @@ class OC_App{
*/
public static function loadApp($app){
if(is_file(self::getAppPath($app).'/appinfo/app.php')){
+ self::checkUpgrade($app);
require_once( $app.'/appinfo/app.php' );
}
}
@@ -526,22 +527,17 @@ class OC_App{
}
/**
- * check if any apps need updating and update those
+ * check if the app need updating and update when needed
*/
- public static function updateApps(){
+ public static function checkUpgrade($app) {
$versions = self::getAppVersions();
- //ensure files app is installed for upgrades
- if(!isset($versions['files'])){
- $versions['files']='0';
- }
- foreach( $versions as $app=>$installedVersion ){
- $currentVersion=OC_App::getAppVersion($app);
- if ($currentVersion) {
- if (version_compare($currentVersion, $installedVersion, '>')) {
- OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion,OC_Log::DEBUG);
- OC_App::updateApp($app);
- OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
- }
+ $currentVersion=OC_App::getAppVersion($app);
+ if ($currentVersion) {
+ $installedVersion = $versions[$app];
+ if (version_compare($currentVersion, $installedVersion, '>')) {
+ OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion,OC_Log::DEBUG);
+ OC_App::updateApp($app);
+ OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
}
}
}
@@ -571,6 +567,10 @@ class OC_App{
* get the installed version of all papps
*/
public static function getAppVersions(){
+ static $versions;
+ if (isset($versions)) { // simple cache, needs to be fixed
+ return $versions; // when function is used besides in checkUpgrade
+ }
$versions=array();
$query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = \'installed_version\'' );
$result = $query->execute();
diff --git a/lib/base.php b/lib/base.php
index b4da6434e25..c2b0bbef780 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -170,8 +170,10 @@ class OC{
public static function checkInstalled() {
// Redirect to installer if not installed
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
- $url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
- header("Location: $url");
+ if(!OC::$CLI){
+ $url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
+ header("Location: $url");
+ }
exit();
}
}
@@ -180,7 +182,7 @@ class OC{
// redirect to https site if configured
if( OC_Config::getValue( "forcessl", false )){
ini_set("session.cookie_secure", "on");
- if(OC_Helper::serverProtocol()<>'https') {
+ if(OC_Helper::serverProtocol()<>'https' and !OC::$CLI) {
$url = "https://". OC_Helper::serverHost() . $_SERVER['REQUEST_URI'];
header("Location: $url");
exit();
@@ -208,9 +210,9 @@ class OC{
OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
OC_App::checkAppsRequirements();
+ // load all apps to also upgrade enabled apps
+ OC_App::loadApps();
}
-
- OC_App::updateApps();
}
}
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 9832449af3a..b75bb5c50f5 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -90,16 +90,18 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
foreach($folder_content as $info) {
$paths[] = $this->path.'/'.$info['name'];
}
- $placeholders = join(',', array_fill(0, count($paths), '?'));
- $query = OC_DB::prepare( 'SELECT * FROM *PREFIX*properties WHERE userid = ?' . ' AND propertypath IN ('.$placeholders.')' );
- array_unshift($paths, OC_User::getUser()); // prepend userid
- $result = $query->execute( $paths );
$properties = array_fill_keys($paths, array());
- while($row = $result->fetchRow()) {
- $propertypath = $row['propertypath'];
- $propertyname = $row['propertyname'];
- $propertyvalue = $row['propertyvalue'];
- $properties[$propertypath][$propertyname] = $propertyvalue;
+ if(count($paths)>0){
+ $placeholders = join(',', array_fill(0, count($paths), '?'));
+ $query = OC_DB::prepare( 'SELECT * FROM *PREFIX*properties WHERE userid = ?' . ' AND propertypath IN ('.$placeholders.')' );
+ array_unshift($paths, OC_User::getUser()); // prepend userid
+ $result = $query->execute( $paths );
+ while($row = $result->fetchRow()) {
+ $propertypath = $row['propertypath'];
+ $propertyname = $row['propertyname'];
+ $propertyvalue = $row['propertyvalue'];
+ $properties[$propertypath][$propertyname] = $propertyvalue;
+ }
}
$nodes = array();
diff --git a/lib/helper.php b/lib/helper.php
index 37914b73e17..6ab55f27618 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -75,6 +75,9 @@ class OC_Helper {
* reverse proxies
*/
public static function serverHost() {
+ if(OC::$CLI){
+ return 'localhost';
+ }
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ",") !== false) {
$host = trim(array_pop(explode(",", $_SERVER['HTTP_X_FORWARDED_HOST'])));
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 1e79b62f0d6..8157c343868 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -55,7 +55,7 @@ class OC_VCategories {
$this->app = $app;
$this->user = is_null($user) ? OC_User::getUser() : $user;
$categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
- $this->categories = $categories != '' ? unserialize($categories) : $defcategories;
+ $this->categories = $categories != '' ? @unserialize($categories) : $defcategories;
}
/**
@@ -64,6 +64,9 @@ class OC_VCategories {
*/
public function categories() {
//OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG);
+ if(!$this->categories) {
+ return array();
+ }
usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
return $this->categories;
}
@@ -203,11 +206,17 @@ class OC_VCategories {
// case-insensitive in_array
private function in_arrayi($needle, $haystack) {
+ if(!is_array($haystack)) {
+ return false;
+ }
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
// case-insensitive array_search
private function array_searchi($needle, $haystack) {
+ if(!is_array($haystack)) {
+ return false;
+ }
return array_search(strtolower($needle),array_map('strtolower',$haystack));
}