summaryrefslogtreecommitdiffstats
path: root/lib/app.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-03-30 13:48:44 +0200
committerRobin Appelman <icewind@owncloud.com>2012-03-30 14:08:18 +0200
commit7bc9fa765c75846e5a293ea534505d3722d612f5 (patch)
treebd718d652bbfa279cf54414759a6d3d667dde08a /lib/app.php
parentf74d11c0c3c4a3bcd733499edd63f8e31389a3a3 (diff)
downloadnextcloud-server-7bc9fa765c75846e5a293ea534505d3722d612f5.tar.gz
nextcloud-server-7bc9fa765c75846e5a293ea534505d3722d612f5.zip
optimizations for updateApps
Diffstat (limited to 'lib/app.php')
-rwxr-xr-xlib/app.php29
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/app.php b/lib/app.php
index 3daf539aa21..5ee9a0e5654 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'];
@@ -396,6 +396,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
*/