ticket-723.diff

Patch to allow disabling pre-serializing, per driver. And disable it for the memcache driver - Mark van der Velden -, 11/08/2008 04:05 pm

Download (1.7 kB)

 
classes/cache.php (working copy)
117 117

  
118 118
		if ($data = $this->driver->get($id))
119 119
		{
120
			if (substr($data, 0, 14) === '<{serialized}>')
120
			if ($this->driver->serialize === true && substr($data, 0, 14) === '<{serialized}>')
121 121
			{
122 122
				// Data has been serialized, unserialize now
123 123
				$data = unserialize(substr($data, 14));
......
172 172
		// Change slashes to colons
173 173
		$id = str_replace(array('/', '\\'), '=', $id);
174 174

  
175
		if ( ! is_string($data))
175
		if ($this->driver->serialize === true && ! is_string($data))
176 176
		{
177 177
			// Serialize all non-string data, so that types can be preserved
178 178
			$data = '<{serialized}>'.serialize($data);
classes/cache/driver.php (working copy)
10 10
 * @license    http://kohanaphp.com/license.html
11 11
 */
12 12
abstract class Cache_Driver {
13
	
14
	/**
15
	 * A driver specific overridable serialize setting,
16
	 * false means the driver takes care of serializing.
17
	 * 
18
	 * @var boolean
19
	 */
20
	public $serialize	= true;
13 21

  
14 22
	/**
15 23
	 * Set a cache item.
classes/cache/driver/memcache.php (working copy)
14 14
	// Cache backend object and flags
15 15
	protected $backend;
16 16
	protected $flags;
17
	
18
	/**
19
	 * Disable serializing in our cache driver
20
	 * 
21
	 * @var boolean
22
	 */
23
	public	$serialize	= false;
17 24

  
18 25
	public function __construct()
19 26
	{