[Pkg-owncloud-commits] [owncloud] 23/153: Use limit=1 so the db can stop searching on the first hit

David Prévot taffit at moszumanska.debian.org
Tue May 27 03:05:28 UTC 2014


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

taffit pushed a commit to branch master
in repository owncloud.

commit 47d70da2f5cb55ad47023b061b68062dd8b8d8e2
Author: Bart Visscher <bartv at thisnet.nl>
Date:   Fri Feb 28 09:29:20 2014 +0100

    Use limit=1 so the db can stop searching on the first hit
---
 lib/public/share.php | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/public/share.php b/lib/public/share.php
index 8cfe741..cc4bfb6 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -243,6 +243,10 @@ class Share {
 		return array("users" => array_unique($shares), "public" => $publicShare);
 	}
 
+	/**
+	 * Check if the current user has files shared with
+	 * @return boolean
+	 */
 	public static function hasFilesSharedWith() {
 		if (!self::isEnabled()) {
 			return false;
@@ -262,8 +266,11 @@ class Share {
 		// Don't include own group shares
 		$where .= ' AND `uid_owner` != ?';
 		$queryArgs[] = $shareWith;
-		$result = \OC_DB::executeAudited('SELECT COUNT(*) FROM `*PREFIX*share` '.$where, $queryArgs);
-		return $result->fetchOne() > 0;
+		$result = \OC_DB::executeAudited(array(
+				'sql' => 'SELECT * FROM `*PREFIX*share` '.$where,
+				'limit' => 1,
+			), $queryArgs);
+		return (bool)$result->fetchOne();
 	}
 
 	/**

-- 
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