Completed
Push — master ( 9a433b...506aa3 )
by Fabio
10:24
created
framework/Caching/TMemCache.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TMemCache class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @author Carl G. Mathisen <[email protected]>
7
- * @link https://github.com/pradosoft/prado
8
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
9
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
10
- * @package System.Caching
11
- */
3
+	 * TMemCache class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @author Carl G. Mathisen <[email protected]>
7
+	 * @link https://github.com/pradosoft/prado
8
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
9
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
10
+	 * @package System.Caching
11
+	 */
12 12
 
13 13
 /**
14 14
  * TMemCache class
@@ -104,30 +104,30 @@  discard block
 block discarded – undo
104 104
 	/**
105 105
 	 * @var boolean controls the use of a persistent connection. Default to true.
106 106
 	 */
107
-    private $_persistence = true;
108
-    /**
109
-     * @var integer number of buckets to create for this server which in turn control its
110
-     * probability of it being selected. The probability is relative to the total weight
111
-     * of all servers.
112
-     */
113
-    private $_weight = 1;
107
+	private $_persistence = true;
108
+	/**
109
+	 * @var integer number of buckets to create for this server which in turn control its
110
+	 * probability of it being selected. The probability is relative to the total weight
111
+	 * of all servers.
112
+	 */
113
+	private $_weight = 1;
114 114
 
115
-    private $_timeout = 360;
115
+	private $_timeout = 360;
116 116
 
117
-    private $_retryInterval = 15;
117
+	private $_retryInterval = 15;
118 118
 	/**
119
-	* @var integer Controls the minimum value length before attempting to compress automatically.
120
-	*/
121
-    private $_threshold=0;
119
+	 * @var integer Controls the minimum value length before attempting to compress automatically.
120
+	 */
121
+	private $_threshold=0;
122 122
 
123 123
 	/**
124
-	* @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings.
125
-	*/
126
-    private $_minSavings=0.0;
124
+	 * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings.
125
+	 */
126
+	private $_minSavings=0.0;
127 127
 
128
-    private $_status = true;
128
+	private $_status = true;
129 129
 
130
-    private $_failureCallback = null;
130
+	private $_failureCallback = null;
131 131
 
132 132
 	/**
133 133
 	 * @var boolean whether to use memcached or memcache as the underlying caching extension.
@@ -171,63 +171,63 @@  discard block
 block discarded – undo
171 171
 		$this->_cache = $this->_useMemcached ? new Memcached : new Memcache;
172 172
 		$this->loadConfig($config);
173 173
 		if(count($this->_servers))
174
-        {
175
-            foreach($this->_servers as $server)
176
-            {
177
-                Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache');
178
-                if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'],
179
-                    $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false)
180
-                    throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']);
181
-            }
182
-        }
183
-        else
184
-        {
185
-            Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache');
186
-            if($this->_cache->addServer($this->_host,$this->_port)===false)
187
-                throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port);
188
-        }
174
+		{
175
+			foreach($this->_servers as $server)
176
+			{
177
+				Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache');
178
+				if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'],
179
+					$server['Weight'],$server['Timeout'],$server['RetryInterval'])===false)
180
+					throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']);
181
+			}
182
+		}
183
+		else
184
+		{
185
+			Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache');
186
+			if($this->_cache->addServer($this->_host,$this->_port)===false)
187
+				throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port);
188
+		}
189 189
 		if($this->_threshold!==0)
190
-            $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings);
190
+			$this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings);
191 191
 		$this->_initialized=true;
192 192
 		parent::init($config);
193 193
 	}
194 194
 
195
-    /**
195
+	/**
196 196
 	 * Loads configuration from an XML element
197 197
 	 * @param TXmlElement configuration node
198 198
 	 * @throws TConfigurationException if log route class or type is not specified
199 199
 	 */
200 200
 	private function loadConfig($xml)
201 201
 	{
202
-	    if($xml instanceof TXmlElement)
202
+		if($xml instanceof TXmlElement)
203 203
 		{
204
-    		foreach($xml->getElementsByTagName('server') as $serverConfig)
205
-    		{
206
-    			$properties=$serverConfig->getAttributes();
207
-    			if(($host=$properties->remove('Host'))===null)
208
-    				throw new TConfigurationException('memcache_serverhost_required');
209
-    			if(($port=$properties->remove('Port'))===null)
210
-        			throw new TConfigurationException('memcache_serverport_required');
211
-        		if(!is_numeric($port))
212
-        		    throw new TConfigurationException('memcache_serverport_invalid');
213
-        		$server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true);
214
-        		$checks = array(
215
-        		    'Weight'=>'memcache_serverweight_invalid',
216
-        		    'Timeout'=>'memcache_servertimeout_invalid',
217
-        		    'RetryInterval'=>'memcach_serverretryinterval_invalid'
218
-        		);
219
-        		foreach($checks as $property=>$exception)
220
-        		{
221
-        		    $value=$properties->remove($property);
222
-        		    if($value!==null && is_numeric($value))
223
-        		        $server[$property]=$value;
224
-        		    else if($value!==null)
225
-        		        throw new TConfigurationException($exception);
226
-        		}
227
-        		$server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent'));
228
-    			$this->_servers[]=$server;
229
-    		}
230
-	    }
204
+			foreach($xml->getElementsByTagName('server') as $serverConfig)
205
+			{
206
+				$properties=$serverConfig->getAttributes();
207
+				if(($host=$properties->remove('Host'))===null)
208
+					throw new TConfigurationException('memcache_serverhost_required');
209
+				if(($port=$properties->remove('Port'))===null)
210
+					throw new TConfigurationException('memcache_serverport_required');
211
+				if(!is_numeric($port))
212
+					throw new TConfigurationException('memcache_serverport_invalid');
213
+				$server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true);
214
+				$checks = array(
215
+					'Weight'=>'memcache_serverweight_invalid',
216
+					'Timeout'=>'memcache_servertimeout_invalid',
217
+					'RetryInterval'=>'memcach_serverretryinterval_invalid'
218
+				);
219
+				foreach($checks as $property=>$exception)
220
+				{
221
+					$value=$properties->remove($property);
222
+					if($value!==null && is_numeric($value))
223
+						$server[$property]=$value;
224
+					else if($value!==null)
225
+						throw new TConfigurationException($exception);
226
+				}
227
+				$server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent'));
228
+				$this->_servers[]=$server;
229
+			}
230
+		}
231 231
 	}
232 232
 
233 233
 	/**
Please login to merge, or discard this patch.
framework/Caching/TEACache.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
1
-<?php
/**
 * TEACache class file
 *
 * @author Dario rigolin <[email protected]>
 * @link https://github.com/pradosoft/prado
 * @copyright Copyright &copy; 2005-2016 The PRADO Group
 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
 * @package System.Caching
 */

/**
 * TEACache class
 *
 * TEACache implements a cache application module based on {@link http://eaccelerator.net/ eAccelerator}.
 *
 * By definition, cache does not ensure the existence of a value
 * even if it never expires. Cache is not meant to be an persistent storage.
 *
 * To use this module, the eAccelerator PHP extension must be loaded and enabled
 *
 * Please note that as of v0.9.6, eAccelerator no longer supports data caching.
 * This means if you still want to use this component, your eAccelerator should be of 0.9.5.x or lower version.
 *
 * Some usage examples of TEACache are as follows,
 * <code>
 * $cache=new TEACache;  // TEACache may also be loaded as a Prado application module
 * $cache->init(null);
 * $cache->add('object',$object);
 * $object2=$cache->get('object');
 * </code>
 *
 * If loaded, TEACache will register itself with {@link TApplication} as the
 * cache module. It can be accessed via {@link TApplication::getCache()}.
 *
 * TEACache may be configured in application configuration file as follows
 * <code>
 * <module id="cache" class="System.Caching.TEACache" />
 * </code>
 *
 * @author Dario Rigolin <[email protected]>
 * @package System.Caching
 * @since 3.2.2
 */
class TEACache extends TCache
{
   /**
    * Initializes this module.
    * This method is required by the IModule interface.
    * @param TXmlElement configuration for this module, can be null
    * @throws TConfigurationException if eaccelerator extension is not installed or not started, check your php.ini
    */
	public function init($config)
	{
		if(!function_exists('eaccelerator_get'))
			throw new TConfigurationException('eacceleratorcache_extension_required');
		parent::init($config);
	}

	/**
	 * Retrieves a value from cache with a specified key.
	 * This is the implementation of the method declared in the parent class.
	 * @param string a unique key identifying the cached value
	 * @return string the value stored in cache, false if the value is not in the cache or expired.
	 */
	protected function getValue($key)
	{
		$value = eaccelerator_get($key);
		return ($value === null) ? false : $value;
	}

	/**
	 * Stores a value identified by a key in cache.
	 * This is the implementation of the method declared in the parent class.
	 *
	 * @param string the key identifying the value to be cached
	 * @param string the value to be cached
	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
	 * @return boolean true if the value is successfully stored into cache, false otherwise
	 */
	protected function setValue($key,$value,$expire)
	{
		return eaccelerator_put($key,$value,$expire);
	}

	/**
	 * Stores a value identified by a key into cache if the cache does not contain this key.
	 * This is the implementation of the method declared in the parent class.
	 *
	 * @param string the key identifying the value to be cached
	 * @param string the value to be cached
	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
	 * @return boolean true if the value is successfully stored into cache, false otherwise
	 */
	protected function addValue($key,$value,$expire)
	{
		return (null === eaccelerator_get($key)) ? $this->setValue($key,$value,$expire) : false;
	}

	/**
	 * Deletes a value with the specified key from cache
	 * This is the implementation of the method declared in the parent class.
	 * @param string the key of the value to be deleted
	 * @return boolean if no error happens during deletion
	 */
	protected function deleteValue($key)
	{
		return eaccelerator_rm($key);
	}

	/**
	 * Deletes all values from cache.
	 * Be careful of performing this operation if the cache is shared by multiple applications.
	 */
	public function flush()
	{
		// first, remove expired content from cache
		eaccelerator_gc();
		// now, remove leftover cache-keys
		$keys = eaccelerator_list_keys();
		foreach($keys as $key)
			$this->deleteValue(substr($key['name'], 1));
		return true;
	}
}
2 1
\ No newline at end of file
2
+<?php
/**
 * TEACache class file
 *
 * @author Dario rigolin <[email protected]>
 * @link https://github.com/pradosoft/prado
 * @copyright Copyright &copy; 2005-2016 The PRADO Group
 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
 * @package System.Caching
 */

/**
 * TEACache class
 *
 * TEACache implements a cache application module based on {@link http://eaccelerator.net/ eAccelerator}.
 *
 * By definition, cache does not ensure the existence of a value
 * even if it never expires. Cache is not meant to be an persistent storage.
 *
 * To use this module, the eAccelerator PHP extension must be loaded and enabled
 *
 * Please note that as of v0.9.6, eAccelerator no longer supports data caching.
 * This means if you still want to use this component, your eAccelerator should be of 0.9.5.x or lower version.
 *
 * Some usage examples of TEACache are as follows,
 * <code>
 * $cache=new TEACache;  // TEACache may also be loaded as a Prado application module
 * $cache->init(null);
 * $cache->add('object',$object);
 * $object2=$cache->get('object');
 * </code>
 *
 * If loaded, TEACache will register itself with {@link TApplication} as the
 * cache module. It can be accessed via {@link TApplication::getCache()}.
 *
 * TEACache may be configured in application configuration file as follows
 * <code>
 * <module id="cache" class="System.Caching.TEACache" />
 * </code>
 *
 * @author Dario Rigolin <[email protected]>
 * @package System.Caching
 * @since 3.2.2
 */
class TEACache extends TCache {
   /**
    * Initializes this module.
    * This method is required by the IModule interface.
    * @param TXmlElement configuration for this module, can be null
    * @throws TConfigurationException if eaccelerator extension is not installed or not started, check your php.ini
    */
	public function init($config) {
		if(!function_exists('eaccelerator_get'))
			throw new TConfigurationException('eacceleratorcache_extension_required'); parent::init($config); }

	/**
	 * Retrieves a value from cache with a specified key.
	 * This is the implementation of the method declared in the parent class.
	 * @param string a unique key identifying the cached value
	 * @return string the value stored in cache, false if the value is not in the cache or expired.
	 */
	protected function getValue($key) {
		$value=eaccelerator_get($key); return ($value===null) ? false : $value; }

	/**
	 * Stores a value identified by a key in cache.
	 * This is the implementation of the method declared in the parent class.
	 *
	 * @param string the key identifying the value to be cached
	 * @param string the value to be cached
	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
	 * @return boolean true if the value is successfully stored into cache, false otherwise
	 */
	protected function setValue($key, $value, $expire) {
		return eaccelerator_put($key, $value, $expire); }

	/**
	 * Stores a value identified by a key into cache if the cache does not contain this key.
	 * This is the implementation of the method declared in the parent class.
	 *
	 * @param string the key identifying the value to be cached
	 * @param string the value to be cached
	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
	 * @return boolean true if the value is successfully stored into cache, false otherwise
	 */
	protected function addValue($key, $value, $expire) {
		return (null===eaccelerator_get($key)) ? $this->setValue($key, $value, $expire) : false; }

	/**
	 * Deletes a value with the specified key from cache
	 * This is the implementation of the method declared in the parent class.
	 * @param string the key of the value to be deleted
	 * @return boolean if no error happens during deletion
	 */
	protected function deleteValue($key) {
		return eaccelerator_rm($key); }

	/**
	 * Deletes all values from cache.
	 * Be careful of performing this operation if the cache is shared by multiple applications.
	 */
	public function flush() {
		// first, remove expired content from cache
		eaccelerator_gc(); // now, remove leftover cache-keys
		$keys=eaccelerator_list_keys(); foreach($keys as $key)
			$this->deleteValue(substr($key['name'], 1)); return true; }
}
3 3
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/TUrlManager.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TUrlManager class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @version $Id $
10
- * @package System.Web
11
- */
3
+	 * TUrlManager class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @version $Id $
10
+	 * @package System.Web
11
+	 */
12 12
 
13 13
 /**
14 14
  * TUrlManager class
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TExpression.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TExpression class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TExpression class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Web.UI.WebControls
10
+	 */
11 11
 
12 12
 /**
13 13
  * TExpression class
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TRepeater.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TRepeater class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TRepeater class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Web.UI.WebControls
10
+	 */
11 11
 
12 12
 /**
13 13
  * Using TDataBoundControl and TDataFieldAccessor cass
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TSafeHtml.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TSafeHtml class file
4
- *
5
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TSafeHtml class file
4
+	 *
5
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Web.UI.WebControls
10
+	 */
11 11
 
12 12
 /**
13 13
  * TSafeHtml class
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TImageMap.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TImageMap and related class file.
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TImageMap and related class file.
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Web.UI.WebControls
10
+	 */
11 11
 
12 12
 /**
13 13
  * Includes TImage class file
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TBaseValidator.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TBaseValidator class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TBaseValidator class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Web.UI.WebControls
10
+	 */
11 11
 
12 12
 /**
13 13
  * Using TLabel class
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TLiteralColumn.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TLiteralColumn class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TLiteralColumn class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2016 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Web.UI.WebControls
10
+	 */
11 11
 
12 12
 /**
13 13
  * TDataGridColumn class file
Please login to merge, or discard this patch.