Completed
Pull Request — release-2.1 (#4447)
by Martyn
16:28 queued 07:45
created
Sources/CacheAPI-sqlite.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function cleanCache($type = '')
110 110
 	{
111
-		if($type == 'expired')
112
-			$query = 'DELETE FROM cache WHERE ttl >= ' . time().';';
111
+		if ($type == 'expired')
112
+			$query = 'DELETE FROM cache WHERE ttl >= ' . time() . ';';
113 113
 		else
114 114
 			$query = 'DELETE FROM cache;';
115 115
 
116 116
 		$result = $this->cacheDB->exec($query);
117 117
 		
118
-		$query	= 'VACUUM;';
118
+		$query = 'VACUUM;';
119 119
 		$this->cacheDB->exec($query);
120 120
 
121 121
 		return $result;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 		// If its invalid, use SMF's.
158 158
 		if (is_null($dir) || !is_writable($dir))
159
-			if(is_null($cachedir_sqlite) || !is_writable($cachedir_sqlite))
159
+			if (is_null($cachedir_sqlite) || !is_writable($cachedir_sqlite))
160 160
 				$this->cachedir = $cachedir;
161 161
 			else
162 162
 				$this->cachedir = $cachedir_sqlite;
Please login to merge, or discard this patch.
Braces   +24 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * SQLite Cache API class
@@ -68,8 +69,9 @@  discard block
 block discarded – undo
68 69
 	{
69 70
 		$supported = class_exists("SQLite3") && is_writable($this->cachedir);
70 71
 
71
-		if ($test)
72
-			return $supported;
72
+		if ($test) {
73
+					return $supported;
74
+		}
73 75
 
74 76
 		return parent::isSupported() && $supported;
75 77
 	}
@@ -84,8 +86,9 @@  discard block
 block discarded – undo
84 86
 		$result = $this->cacheDB->query($query);
85 87
 
86 88
 		$value = null;
87
-		while ($res = $result->fetchArray(SQLITE3_ASSOC))
88
-			$value = $res['value'];
89
+		while ($res = $result->fetchArray(SQLITE3_ASSOC)) {
90
+					$value = $res['value'];
91
+		}
89 92
 
90 93
 		return !empty($value) ? $value : null;
91 94
 	}
@@ -108,10 +111,11 @@  discard block
 block discarded – undo
108 111
 	 */
109 112
 	public function cleanCache($type = '')
110 113
 	{
111
-		if($type == 'expired')
112
-			$query = 'DELETE FROM cache WHERE ttl >= ' . time().';';
113
-		else
114
-			$query = 'DELETE FROM cache;';
114
+		if($type == 'expired') {
115
+					$query = 'DELETE FROM cache WHERE ttl >= ' . time().';';
116
+		} else {
117
+					$query = 'DELETE FROM cache;';
118
+		}
115 119
 
116 120
 		$result = $this->cacheDB->exec($query);
117 121
 		
@@ -131,8 +135,9 @@  discard block
 block discarded – undo
131 135
 		$config_vars[] = $txt['cache_sqlite_settings'];
132 136
 		$config_vars[] = array('cachedir_sqlite', $txt['cachedir_sqlite'], 'file', 'text', 36, 'cache_sqlite_cachedir');
133 137
 
134
-		if (!isset($context['settings_post_javascript']))
135
-			$context['settings_post_javascript'] = '';
138
+		if (!isset($context['settings_post_javascript'])) {
139
+					$context['settings_post_javascript'] = '';
140
+		}
136 141
 
137 142
 		$context['settings_post_javascript'] .= '
138 143
 			$("#cache_accelerator").change(function (e) {
@@ -155,13 +160,15 @@  discard block
 block discarded – undo
155 160
 		global $cachedir, $cachedir_sqlite;
156 161
 
157 162
 		// If its invalid, use SMF's.
158
-		if (is_null($dir) || !is_writable($dir))
159
-			if(is_null($cachedir_sqlite) || !is_writable($cachedir_sqlite))
163
+		if (is_null($dir) || !is_writable($dir)) {
164
+					if(is_null($cachedir_sqlite) || !is_writable($cachedir_sqlite))
160 165
 				$this->cachedir = $cachedir;
161
-			else
162
-				$this->cachedir = $cachedir_sqlite;
163
-		else
164
-			$this->cachedir = $dir;
166
+		} else {
167
+							$this->cachedir = $cachedir_sqlite;
168
+			}
169
+		else {
170
+					$this->cachedir = $dir;
171
+		}
165 172
 	}
166 173
 
167 174
 	/**
Please login to merge, or discard this patch.