[Pkg-owncloud-commits] [owncloud] 04/10: 14719 without public API

David Prévot taffit at moszumanska.debian.org
Wed Mar 11 15:50:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.0.2
in repository owncloud.

commit 6d5e60bd9b801b2fe8dde2c947aa31b1d2b6ae87
Author: Lukas Reschke <lukas at owncloud.com>
Date:   Thu Mar 5 22:34:46 2015 +0100

    14719 without public API
---
 lib/private/allconfig.php | 32 --------------------------------
 lib/private/app.php       | 32 ++++++++++++++++++++++++--------
 lib/public/iconfig.php    | 10 ----------
 tests/lib/allconfig.php   | 27 ---------------------------
 4 files changed, 24 insertions(+), 77 deletions(-)

diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php
index ff470b3..d729936 100644
--- a/lib/private/allconfig.php
+++ b/lib/private/allconfig.php
@@ -162,38 +162,6 @@ class AllConfig implements \OCP\IConfig {
 	}
 
 	/**
-	 * Determines the apps that have the set the value for the specified
-	 * keys
-	 *
-	 * @param string $value the value to get the app for
-	 * @param string $key the key too lookup
-	 * @return array of app IDs
-	 */
-	public function getAppsForKeyValue($key, $value) {
-		// TODO - FIXME
-		$this->fixDIInit();
-
-		$qb = $this->connection->createQueryBuilder();
-		$qb
-			->select('appid')
-			->from('`*PREFIX*appconfig`')
-			->where('configvalue = ?')
-			->andWhere('configkey = ?')
-			->setParameter(0, $value)
-			->setParameter(1, $key)
-		;
-		$result = $qb->execute();
-
-		$appIDs = [];
-		while ($row = $result->fetch()) {
-			$appIDs[] = $row['appid'];
-		}
-
-		sort($appIDs);
-		return $appIDs;
-	}
-
-	/**
 	 * Set a user defined value
 	 *
 	 * @param string $userId the userId of the user that we want to store the value under
diff --git a/lib/private/app.php b/lib/private/app.php
index c12447d..d3dcf1f 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -330,8 +330,8 @@ class OC_App {
 		\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
 
 		// Convert OCS ID to regular application identifier
-		if(is_numeric($app)) {
-			$app = \OC::$server->getConfig()->getAppsForKeyValue('ocsid', $app)[0];
+		if(self::getInternalAppIdByOcs($app) !== false) {
+			$app = self::getInternalAppIdByOcs($app);
 		}
 
 		OC_Appconfig::setValue($app, 'enabled', 'no' );
@@ -904,6 +904,21 @@ class OC_App {
 	}
 
 	/**
+	 * Returns the internal app ID or false
+	 * @param string $ocsID
+	 * @return string|false
+	 */
+	protected static function getInternalAppIdByOcs($ocsID) {
+		if(is_numeric($ocsID)) {
+			$idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid');
+			if(array_search($ocsID, $idArray)) {
+				return array_search($ocsID, $idArray);
+			}
+		}
+		return false;
+	}
+
+	/**
 	 * get a list of all apps on apps.owncloud.com
 	 * @return array, multi-dimensional array of apps.
 	 *     Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description
@@ -928,12 +943,13 @@ class OC_App {
 		$i = 0;
 		$l = \OC::$server->getL10N('core');
 		foreach ($remoteApps as $app) {
+			$potentialCleanId = self::getInternalAppIdByOcs($app['id']);
 			// enhance app info (for example the description)
 			$app1[$i] = OC_App::parseAppInfo($app);
 			$app1[$i]['author'] = $app['personid'];
 			$app1[$i]['ocs_id'] = $app['id'];
 			$app1[$i]['internal'] = 0;
-			$app1[$i]['active'] = self::isEnabled(\OC::$server->getConfig()->getAppsForKeyValue('ocsid', $app['id'])[0]);
+			$app1[$i]['active'] = ($potentialCleanId !== false) ? self::isEnabled($potentialCleanId) : false;
 			$app1[$i]['update'] = false;
 			$app1[$i]['groups'] = false;
 			$app1[$i]['score'] = $app['score'];
@@ -1086,13 +1102,13 @@ class OC_App {
 			// Maybe the app is already installed - compare the version in this
 			// case and use the local already installed one.
 			// FIXME: This is a horrible hack. I feel sad. The god of code cleanness may forgive me.
-			$internalAppId = $config->getAppsForKeyValue('ocsid', $app);
-			if(isset($internalAppId[0])) {
-				if($appData && version_compare(\OC_App::getAppVersion($internalAppId[0]), $appData['version'], '<')) {
+			$internalAppId = self::getInternalAppIdByOcs($app);
+			if($internalAppId !== false) {
+				if($appData && version_compare(\OC_App::getAppVersion($internalAppId), $appData['version'], '<')) {
 					$app = self::downloadApp($app);
 				} else {
-					self::enable($internalAppId[0]);
-					$app = $internalAppId[0];
+					self::enable($internalAppId);
+					$app = $internalAppId;
 				}
 			} else {
 				$app = self::downloadApp($app);
diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php
index 06638d0..96384ce 100644
--- a/lib/public/iconfig.php
+++ b/lib/public/iconfig.php
@@ -110,16 +110,6 @@ interface IConfig {
 	public function deleteAppValues($appName);
 
 	/**
-	 * Determines the apps that have the set the value for the specified
-	 * keys
-	 *
-	 * @param string $value the value to get the app for
-	 * @param string $key the key too lookup
-	 * @return array of app IDs
-	 */
-	public function getAppsForKeyValue($key, $value);
-
-	/**
 	 * Set a user defined value
 	 *
 	 * @param string $userId the userId of the user that we want to store the value under
diff --git a/tests/lib/allconfig.php b/tests/lib/allconfig.php
index 290e40e..7f8ad5e 100644
--- a/tests/lib/allconfig.php
+++ b/tests/lib/allconfig.php
@@ -26,33 +26,6 @@ class TestAllConfig extends \Test\TestCase {
 		return new \OC\AllConfig($systemConfig, $connection);
 	}
 
-	// FIXME: Actually an integration test... – Shouldn't be in the unit test at all.
-	public function testGetAppsForKeyValue() {
-		$config = $this->getConfig();
-
-		// preparation - add something to the database
-		$data = [
-			['myFirstApp', 'key1', 'value1'],
-			['mySecondApp', 'key1', 'value2'],
-			['mySecondApp', 'key3', 'value2'],
-			['myThirdApp', 'key3', 'value3'],
-			['myThirdApp', 'key3', 'value2'],
-		];
-		foreach ($data as $entry) {
-			$config->setAppValue($entry[0], $entry[1], $entry[2]);
-		}
-
-		$this->assertEquals(['mySecondApp'], $config->getAppsForKeyValue('key1', 'value2'));
-		$this->assertEquals(['mySecondApp', 'myThirdApp'], $config->getAppsForKeyValue('key3', 'value2'));
-		$this->assertEquals([], $config->getAppsForKeyValue('NotExisting', 'NotExistingValue'));
-
-		// cleanup
-		foreach ($data as $entry) {
-			$config->deleteAppValue($entry[0], $entry[1]);
-
-		}
-	}
-
 	public function testDeleteUserValue() {
 		$config = $this->getConfig();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list