Test Failed
Push — 1.0.0-dev ( 92a7f9...7e13dc )
by nguereza
04:45
created
core/classes/DBSessionHandler.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
23 23
 	 * along with this program; if not, write to the Free Software
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
25
+	 */
26 26
 	
27 27
 	/**
28 28
 	 * check if the interface "SessionHandlerInterface" exists (normally in PHP 5.4 this already exists)
@@ -76,27 +76,27 @@  discard block
 block discarded – undo
76 76
 		private $logger;
77 77
 
78 78
 		/**
79
-         * Instance of the Loader class
80
-         * @var Loader
81
-         */
82
-        protected $loader = null;
79
+		 * Instance of the Loader class
80
+		 * @var Loader
81
+		 */
82
+		protected $loader = null;
83 83
 
84 84
 		public function __construct(DBSessionHandlerModel $modelInstance = null, Log $logger = null, Loader $loader = null){
85 85
 			/**
86
-	         * instance of the Log class
87
-	         */
88
-	        if(is_object($logger)){
89
-	          $this->setLogger($logger);
90
-	        }
91
-	        else{
92
-	            $this->logger =& class_loader('Log', 'classes');
93
-	            $this->logger->setLogger('Library::DBSessionHandler');
94
-	        }
95
-
96
-	        if(is_object($loader)){
97
-	          $this->setLoader($loader);
98
-	        }
99
-		    $this->OBJ = & get_instance();
86
+			 * instance of the Log class
87
+			 */
88
+			if(is_object($logger)){
89
+			  $this->setLogger($logger);
90
+			}
91
+			else{
92
+				$this->logger =& class_loader('Log', 'classes');
93
+				$this->logger->setLogger('Library::DBSessionHandler');
94
+			}
95
+
96
+			if(is_object($loader)){
97
+			  $this->setLoader($loader);
98
+			}
99
+			$this->OBJ = & get_instance();
100 100
 
101 101
 		    
102 102
 			if(is_object($modelInstance)){
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 				$this->getLoader()->library('Browser'); 
200 200
 			}
201 201
 			else{
202
-            	Loader::functions('user_agent');
203
-            	Loader::library('Browser');
204
-            }
202
+				Loader::functions('user_agent');
203
+				Loader::library('Browser');
204
+			}
205 205
 			
206 206
 			$ip = get_ip();
207 207
 			$host = @gethostbyaddr($ip) or null;
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 				$this->getLoader()->library('Browser'); 
239 239
 			}
240 240
 			else{
241
-            	Loader::functions('user_agent');
242
-            	Loader::library('Browser');
243
-            }
241
+				Loader::functions('user_agent');
242
+				Loader::library('Browser');
243
+			}
244 244
 
245 245
 			$ip = get_ip();
246 246
 			$keyValue = $instance->getKeyValue();
@@ -324,75 +324,75 @@  discard block
 block discarded – undo
324 324
 
325 325
 		
326 326
 		/**
327
-         * Return the loader instance
328
-         * @return object Loader the loader instance
329
-         */
330
-        public function getLoader(){
331
-            return $this->loader;
332
-        }
333
-
334
-        /**
335
-         * set the loader instance for future use
336
-         * @param object Loader $loader the loader object
337
-         */
338
-         public function setLoader($loader){
339
-            $this->loader = $loader;
340
-            return $this;
341
-        }
342
-
343
-        /**
344
-         * Return the model instance
345
-         * @return object DBSessionHandlerModel the model instance
346
-         */
347
-        public function getModelInstance(){
348
-            return $this->modelInstanceName;
349
-        }
350
-
351
-        /**
352
-         * set the model instance for future use
353
-         * @param DBSessionHandlerModel $modelInstance the model object
354
-         */
355
-         public function setModelInstance(DBSessionHandlerModel $modelInstance){
356
-            $this->modelInstanceName = $modelInstance;
357
-            return $this;
358
-        }
359
-
360
-        /**
361
-	     * Return the Log instance
362
-	     * @return Log
363
-	     */
364
-	    public function getLogger(){
365
-	      return $this->logger;
366
-	    }
367
-
368
-	    /**
369
-	     * Set the log instance
370
-	     * @param Log $logger the log object
371
-	     */
372
-	    public function setLogger(Log $logger){
373
-	      $this->logger = $logger;
374
-	      return $this;
375
-	    }
376
-
377
-	    /**
378
-	     * Set the model instance using the configuration for session
379
-	     */
380
-	    private function setModelInstanceFromConfig(){
381
-	    	$modelName = get_config('session_save_path');
327
+		 * Return the loader instance
328
+		 * @return object Loader the loader instance
329
+		 */
330
+		public function getLoader(){
331
+			return $this->loader;
332
+		}
333
+
334
+		/**
335
+		 * set the loader instance for future use
336
+		 * @param object Loader $loader the loader object
337
+		 */
338
+		 public function setLoader($loader){
339
+			$this->loader = $loader;
340
+			return $this;
341
+		}
342
+
343
+		/**
344
+		 * Return the model instance
345
+		 * @return object DBSessionHandlerModel the model instance
346
+		 */
347
+		public function getModelInstance(){
348
+			return $this->modelInstanceName;
349
+		}
350
+
351
+		/**
352
+		 * set the model instance for future use
353
+		 * @param DBSessionHandlerModel $modelInstance the model object
354
+		 */
355
+		 public function setModelInstance(DBSessionHandlerModel $modelInstance){
356
+			$this->modelInstanceName = $modelInstance;
357
+			return $this;
358
+		}
359
+
360
+		/**
361
+		 * Return the Log instance
362
+		 * @return Log
363
+		 */
364
+		public function getLogger(){
365
+		  return $this->logger;
366
+		}
367
+
368
+		/**
369
+		 * Set the log instance
370
+		 * @param Log $logger the log object
371
+		 */
372
+		public function setLogger(Log $logger){
373
+		  $this->logger = $logger;
374
+		  return $this;
375
+		}
376
+
377
+		/**
378
+		 * Set the model instance using the configuration for session
379
+		 */
380
+		private function setModelInstanceFromConfig(){
381
+			$modelName = get_config('session_save_path');
382 382
 			$this->logger->info('The database session model: ' . $modelName);
383 383
 			if($this->getLoader()){
384 384
 				$this->getLoader()->model($modelName, 'dbsessionhandlerinstance'); 
385 385
 			}
386 386
 			//@codeCoverageIgnoreStart
387 387
 			else{
388
-            	Loader::model($modelName, 'dbsessionhandlerinstance'); 
389
-            }
390
-            if(isset($this->OBJ->dbsessionhandlerinstance) && ! $this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel){
388
+				Loader::model($modelName, 'dbsessionhandlerinstance'); 
389
+			}
390
+			if(isset($this->OBJ->dbsessionhandlerinstance) && ! $this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel){
391 391
 				show_error('To use database session handler, your class model "'.get_class($this->OBJ->dbsessionhandlerinstance).'" need extends "DBSessionHandlerModel"');
392 392
 			}  
393 393
 			//@codeCoverageIgnoreEnd
394 394
 			
395 395
 			//set model instance
396 396
 			$this->setModelInstance($this->OBJ->dbsessionhandlerinstance);
397
-	    }
397
+		}
398 398
 	}
Please login to merge, or discard this patch.
core/classes/cache/ApcCache.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
23 23
 	 * along with this program; if not, write to the Free Software
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
25
+	 */
26 26
 	
27 27
 	class ApcCache implements CacheInterface{
28 28
 
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 			}
40 40
 
41 41
 			/**
42
-	         * instance of the Log class
43
-	         */
44
-	        if(is_object($logger)){
45
-	          $this->logger = $logger;
46
-	        }
47
-	        else{
48
-	            $this->logger =& class_loader('Log', 'classes');
49
-	            $this->logger->setLogger('Library::ApcCache');
50
-	        }
42
+			 * instance of the Log class
43
+			 */
44
+			if(is_object($logger)){
45
+			  $this->logger = $logger;
46
+			}
47
+			else{
48
+				$this->logger =& class_loader('Log', 'classes');
49
+				$this->logger->setLogger('Library::ApcCache');
50
+			}
51 51
 		}
52 52
 
53 53
 		/**
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 			$this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
88 88
 			$result = apc_store($key, $data, $ttl);
89 89
 			if($result === false){
90
-		    	$this->logger->error('Can not write cache data for the key ['. $key .'], return false');
91
-		    	return false;
92
-		    }
93
-		    else{
94
-		    	$this->logger->info('Cache data saved for the key ['. $key .']');
95
-		    	return true;
96
-		    }
90
+				$this->logger->error('Can not write cache data for the key ['. $key .'], return false');
91
+				return false;
92
+			}
93
+			else{
94
+				$this->logger->info('Cache data saved for the key ['. $key .']');
95
+				return true;
96
+			}
97 97
 		}
98 98
 
99 99
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 			else{
114 114
 				$this->logger->info('Found cache data for the key [' .$key. '] remove it');
115
-	      		return apc_delete($key) === true;
115
+		  		return apc_delete($key) === true;
116 116
 			}
117 117
 		}
118 118
 		
@@ -177,28 +177,28 @@  discard block
 block discarded – undo
177 177
 		}
178 178
 
179 179
 		/**
180
-	     * Return the Log instance
181
-	     * @return Log
182
-	     */
183
-	    public function getLogger(){
184
-	      return $this->logger;
185
-	    }
180
+		 * Return the Log instance
181
+		 * @return Log
182
+		 */
183
+		public function getLogger(){
184
+		  return $this->logger;
185
+		}
186 186
 
187
-	    /**
188
-	     * Set the log instance
189
-	     * @param Log $logger the log object
190
-	     */
191
-	    public function setLogger(Log $logger){
192
-	      $this->logger = $logger;
193
-	      return $this;
194
-	    }
187
+		/**
188
+		 * Set the log instance
189
+		 * @param Log $logger the log object
190
+		 */
191
+		public function setLogger(Log $logger){
192
+		  $this->logger = $logger;
193
+		  return $this;
194
+		}
195 195
 		
196 196
 		/**
197
-		* Return the array of cache information
198
-		*
199
-		* @param string $key the cache key to get the cache information 
200
-		* @return boolean|array
201
-		*/
197
+		 * Return the array of cache information
198
+		 *
199
+		 * @param string $key the cache key to get the cache information 
200
+		 * @return boolean|array
201
+		 */
202 202
 		private function _getCacheInfo($key){
203 203
 			$caches = apc_cache_info('user');
204 204
 			if(! empty($caches['cache_list'])){
Please login to merge, or discard this patch.
core/classes/cache/FileCache.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
23 23
 	 * along with this program; if not, write to the Free Software
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
25
+	 */
26 26
 
27 27
 	class FileCache implements CacheInterface{
28 28
 		
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
 				show_error('The cache for file system is not available. Check the cache directory if is exists or is writable.');
45 45
 			}
46 46
 			/**
47
-	         * instance of the Log class
48
-	         */
49
-	        if(is_object($logger)){
50
-	          $this->logger = $logger;
51
-	        }
52
-	        else{
53
-	            $this->logger =& class_loader('Log', 'classes');
54
-	            $this->logger->setLogger('Library::FileCache');
55
-	        }
47
+			 * instance of the Log class
48
+			 */
49
+			if(is_object($logger)){
50
+			  $this->logger = $logger;
51
+			}
52
+			else{
53
+				$this->logger =& class_loader('Log', 'classes');
54
+				$this->logger->setLogger('Library::FileCache');
55
+			}
56 56
 			
57 57
 			//if Zlib extension is not loaded set compressCacheData to false
58 58
 			if(! extension_loaded('zlib')){
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
 				return false;
81 81
 			}
82 82
 			// Getting a shared lock 
83
-		    flock($handle, LOCK_SH);
84
-		    $data = file_get_contents($filePath);
85
-      		fclose($handle);
86
-      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
87
-      		if (! $data) {
88
-      			$this->logger->error('Can not unserialize the cache data for the key ['. $key .'], return false');
89
-		         // If unserializing somehow didn't work out, we'll delete the file
90
-		         unlink($filePath);
91
-		         return false;
92
-	      	}
93
-	      	if (time() > $data['expire']) {
94
-	      		$this->logger->info('The cache data for the key ['. $key .'] already expired delete the cache file [' .$filePath. ']');
95
-		        // Unlinking when the file was expired
96
-		        unlink($filePath);
97
-		        return false;
98
-		     }
99
-		     else{
100
-		     	$this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
101
-		     	return $data['data'];
102
-		     }
83
+			flock($handle, LOCK_SH);
84
+			$data = file_get_contents($filePath);
85
+	  		fclose($handle);
86
+	  		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
87
+	  		if (! $data) {
88
+	  			$this->logger->error('Can not unserialize the cache data for the key ['. $key .'], return false');
89
+				 // If unserializing somehow didn't work out, we'll delete the file
90
+				 unlink($filePath);
91
+				 return false;
92
+		  	}
93
+		  	if (time() > $data['expire']) {
94
+		  		$this->logger->info('The cache data for the key ['. $key .'] already expired delete the cache file [' .$filePath. ']');
95
+				// Unlinking when the file was expired
96
+				unlink($filePath);
97
+				return false;
98
+			 }
99
+			 else{
100
+			 	$this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
101
+			 	return $data['data'];
102
+			 }
103 103
 		}
104 104
 
105 105
 
@@ -121,25 +121,25 @@  discard block
 block discarded – undo
121 121
 			}
122 122
 			flock($handle, LOCK_EX); // exclusive lock, will get released when the file is closed
123 123
 			//Serializing along with the TTL
124
-		    $cacheData = serialize(array(
124
+			$cacheData = serialize(array(
125 125
 									'mtime' => time(),
126 126
 									'expire' => $expire,
127 127
 									'data' => $data,
128 128
 									'ttl' => $ttl
129 129
 									)
130 130
 								);		   
131
-		    $result = fwrite($handle, $this->compressCacheData ? gzdeflate($cacheData, 9) : $cacheData);
132
-		    if(! $result){
133
-		    	$this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
134
-		    	fclose($handle);
135
-		    	return false;
136
-		    }
137
-		    else{
138
-		    	$this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
139
-		    	fclose($handle);
131
+			$result = fwrite($handle, $this->compressCacheData ? gzdeflate($cacheData, 9) : $cacheData);
132
+			if(! $result){
133
+				$this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
134
+				fclose($handle);
135
+				return false;
136
+			}
137
+			else{
138
+				$this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
139
+				fclose($handle);
140 140
 				chmod($filePath, 0640);
141 141
 				return true;
142
-		    }
142
+			}
143 143
 		}	
144 144
 
145 145
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			}
160 160
 			else{
161 161
 				$this->logger->info('Found cache file [' .$filePath. '] remove it');
162
-	      		unlink($filePath);
162
+		  		unlink($filePath);
163 163
 				return true;
164 164
 			}
165 165
 		}
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			}
183 183
 			else{
184 184
 				$this->logger->info('Found cache file [' .$filePath. '] check the validity');
185
-	      		$data = file_get_contents($filePath);
185
+		  		$data = file_get_contents($filePath);
186 186
 				$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
187 187
 				if(! $data){
188 188
 					$this->logger->warning('Can not unserialize the cache data for file [' . $filePath . ']');
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
 				foreach ($list as $file) {
223 223
 					$this->logger->debug('Processing the cache file [' . $file . ']');
224 224
 					$data = file_get_contents($file);
225
-		      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
226
-		      		if(! $data){
227
-		      			$this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
228
-		      		}
229
-		      		else if(time() > $data['expire']){
230
-		      			$this->logger->info('The cache data for file [' . $file . '] already expired remove it');
231
-		      			unlink($file);
232
-		      		}
233
-		      		else{
234
-		      			$this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
235
-		      		}
225
+			  		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
226
+			  		if(! $data){
227
+			  			$this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
228
+			  		}
229
+			  		else if(time() > $data['expire']){
230
+			  			$this->logger->info('The cache data for file [' . $file . '] already expired remove it');
231
+			  			unlink($file);
232
+			  		}
233
+			  		else{
234
+			  			$this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
235
+			  		}
236 236
 				}
237 237
 			}
238 238
 		}	
@@ -255,19 +255,19 @@  discard block
 block discarded – undo
255 255
 			}
256 256
 		}
257 257
 	
258
-	    /**
259
-	     * @return boolean
260
-	     */
261
-	    public function isCompressCacheData(){
262
-	        return $this->compressCacheData;
263
-	    }
258
+		/**
259
+		 * @return boolean
260
+		 */
261
+		public function isCompressCacheData(){
262
+			return $this->compressCacheData;
263
+		}
264 264
 
265
-	    /**
266
-	     * @param boolean $compressCacheData
267
-	     *
268
-	     * @return self
269
-	     */
270
-	    public function setCompressCacheData($status = true){
265
+		/**
266
+		 * @param boolean $compressCacheData
267
+		 *
268
+		 * @return self
269
+		 */
270
+		public function setCompressCacheData($status = true){
271 271
 			//if Zlib extension is not loaded set compressCacheData to false
272 272
 			if($status === true && ! extension_loaded('zlib')){
273 273
 				
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 				$this->compressCacheData = $status;
279 279
 			}
280 280
 			return $this;
281
-	    }
281
+		}
282 282
 		
283 283
 		/**
284 284
 		 * Check whether the cache feature for the handle is supported
@@ -290,28 +290,28 @@  discard block
 block discarded – undo
290 290
 		}
291 291
 
292 292
 		/**
293
-	     * Return the Log instance
294
-	     * @return Log
295
-	     */
296
-	    public function getLogger(){
297
-	      return $this->logger;
298
-	    }
293
+		 * Return the Log instance
294
+		 * @return Log
295
+		 */
296
+		public function getLogger(){
297
+		  return $this->logger;
298
+		}
299 299
 
300
-	    /**
301
-	     * Set the log instance
302
-	     * @param Log $logger the log object
303
-	     */
304
-	    public function setLogger(Log $logger){
305
-	      $this->logger = $logger;
306
-	      return $this;
307
-	    }
300
+		/**
301
+		 * Set the log instance
302
+		 * @param Log $logger the log object
303
+		 */
304
+		public function setLogger(Log $logger){
305
+		  $this->logger = $logger;
306
+		  return $this;
307
+		}
308 308
 		
309 309
 		/**
310
-		* Get the cache file full path for the given key
311
-		*
312
-		* @param $key the cache item key
313
-		* @return string the full cache file path for this key
314
-		*/
310
+		 * Get the cache file full path for the given key
311
+		 *
312
+		 * @param $key the cache item key
313
+		 * @return string the full cache file path for this key
314
+		 */
315 315
 		private function getFilePath($key){
316 316
 			return CACHE_PATH . md5($key) . '.cache';
317 317
 		}
Please login to merge, or discard this patch.