From 5ca690e2f8be9fae50a6d29786ab0da9188a71ad Mon Sep 17 00:00:00 2001
From: Robin McCorkell <rmccorkell@owncloud.com>
Date: Thu, 10 Sep 2015 22:01:02 +0100
Subject: [PATCH] Use integer for availability instead of bool

---
 db_structure.xml                    | 4 ++--
 lib/private/files/cache/storage.php | 8 +++++---
 version.php                         | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/db_structure.xml b/db_structure.xml
index c7b7ffec60..6efcf497cf 100644
--- a/db_structure.xml
+++ b/db_structure.xml
@@ -104,8 +104,8 @@
 
 			<field>
 				<name>available</name>
-				<type>boolean</type>
-				<default>true</default>
+				<type>integer</type>
+				<default>1</default>
 				<notnull>true</notnull>
 			</field>
 
diff --git a/lib/private/files/cache/storage.php b/lib/private/files/cache/storage.php
index 338d830828..a116e84b3f 100644
--- a/lib/private/files/cache/storage.php
+++ b/lib/private/files/cache/storage.php
@@ -58,7 +58,8 @@ class Storage {
 			$this->numericId = $row['numeric_id'];
 		} else {
 			$connection = \OC_DB::getConnection();
-			if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $isAvailable])) {
+			$available = $isAvailable ? 1 : 0;
+			if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $available])) {
 				$this->numericId = \OC_DB::insertid('*PREFIX*storages');
 			} else {
 				if ($row = self::getStorageById($this->storageId)) {
@@ -141,7 +142,7 @@ class Storage {
 	public function getAvailability() {
 		if ($row = self::getStorageById($this->storageId)) {
 			return [
-				'available' => $row['available'],
+				'available' => ($row['available'] === 1),
 				'last_checked' => $row['last_checked']
 			];
 		} else {
@@ -154,7 +155,8 @@ class Storage {
 	 */
 	public function setAvailability($isAvailable) {
 		$sql = 'UPDATE `*PREFIX*storages` SET `available` = ?, `last_checked` = ? WHERE `id` = ?';
-		\OC_DB::executeAudited($sql, array($isAvailable, time(), $this->storageId));
+		$available = $isAvailable ? 1 : 0;
+		\OC_DB::executeAudited($sql, array($available, time(), $this->storageId));
 	}
 
 	/**
diff --git a/version.php b/version.php
index a6b49d9dc7..cfc4db8299 100644
--- a/version.php
+++ b/version.php
@@ -23,7 +23,7 @@
 // We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades
 // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
 // when updating major/minor version number.
-$OC_Version = [8, 2, 0, 4];
+$OC_Version = [8, 2, 0, 5];
 
 // The human readable string
 $OC_VersionString = '8.2 pre alpha';
-- 
GitLab