diff --git a/lib/app.php b/lib/app.php
index 3daf539aa210cbce42669c93ba369bb4e69f8e82..5ee9a0e56546b5b0b58f75f822d0bd0bb0c22bd5 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -265,19 +265,20 @@ class OC_App{
 	/**
 	 * @brief Read app metadata from the info.xml file
 	 * @param string $appid id of the app or the path of the info.xml file
+	 * @param boolean path (optional)
 	 * @returns array
 	*/
-	public static function getAppInfo($appid){
-		if(is_file($appid)){
+	public static function getAppInfo($appid,$path=false){
+		if($path){
 			$file=$appid;
 		}else{
 			$file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml';
-			if(!is_file($file)){
-				return array();
-			}
 		}
 		$data=array();
 		$content=file_get_contents($file);
+		if(!$content){
+			return;
+		}
 		$xml = new SimpleXMLElement($content);
 		$data['info']=array();
 		foreach($xml->children() as $child){
@@ -381,9 +382,8 @@ class OC_App{
 	 */
 	public static function updateApps(){
 		// The rest comes here
-		$apps = OC_Appconfig::getApps();
-		foreach( $apps as $app ){
-			$installedVersion=OC_Appconfig::getValue($app,'installed_version');
+		$versions = self::getAppVersions();
+		foreach( $versions as $app=>$installedVersion ){
 			$appInfo=OC_App::getAppInfo($app);
 			if (isset($appInfo['version'])) {
 				$currentVersion=$appInfo['version'];
@@ -395,6 +395,19 @@ class OC_App{
 		}
 	}
 
+	/**
+	 * get the installed version of all papps
+	 */
+	public static function getAppVersions(){
+		$versions=array();
+		$query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = "installed_version"' );
+		$result = $query->execute();
+		while($row = $result->fetchRow()){
+			$versions[$row['appid']]=$row['configvalue'];
+		}
+		return $versions;
+	}
+
 	/**
 	 * update the database for the app and call the update script
 	 * @param string appid
diff --git a/lib/installer.php b/lib/installer.php
index c5ecacae5446715fd4beb41a67c57865a16e9fed..38e17130e3c5ff55b96e9b50cca33457e652b5ab 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -123,7 +123,7 @@ class OC_Installer{
 			}
 			return false;
 		}
-		$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml');
+		$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true);
 		$basedir=OC::$APPSROOT.'/apps/'.$info['id'];
 		
 		//check if an app with the same id is already installed
@@ -296,7 +296,7 @@ class OC_Installer{
 		if(is_file(OC::$APPSROOT."/apps/$app/appinfo/install.php")){
 			include(OC::$APPSROOT."/apps/$app/appinfo/install.php");
 		}
-		$info=OC_App::getAppInfo(OC::$APPSROOT."/apps/$app/appinfo/info.xml");
+		$info=OC_App::getAppInfo($app);
 		OC_Appconfig::setValue($app,'installed_version',$info['version']);
 		return $info;
 	}